Feedback
Did this article resolve your question/issue?

   

Article

How to disconnect any database user from a remote machine using an AppServer

Information

 
TitleHow to disconnect any database user from a remote machine using an AppServer
URL Name000037668
Article Number000159069
EnvironmentProduct: OpenEdge
Version: All Supported Versions
OS: All supported platforms
Question/Problem Description
How to disconnect any database user from a client running on a remote machine (to the database) using an AppServer.
How to run the OS-Command proshut -C disconnect from a remote client session using an AppServer
Steps to Reproduce
Clarifying Information
The client program runs on Windows.
The AppServer program can run on either Windows or UNIX.
Error Message
Defect Number
Enhancement Number
Cause
Resolution
This Article provides a code example to disconnect a database user from a client running on a remote machine (to the database) using an AppServer.

The "proshut -C disconnect" command can only be run on the same machine the database is started. While a remote PROSHUT session is able to disconnect a database user by choosing Option 1 Disconnect a User from the menu presented and entering the user number to disconnect:
proshut dbname -H <host> -S <port> -Mm <bytes>
The same remote proshut session is not able to disconnect that user by adding the '-C disconnect' parameter to the command line. Use of this parameter is limited to local non-networked connections only, you cannot use the "-S" with "disconnect". It will fail with "You cannot run the DISCONNECT from a remote machine. (2259)

The code example below consists of two ABL programs:
  • Apps_shut.p runs on the AppServer side and disconnects the user with the number contained in shut_id.
  • Cli_shut.p runs on the client side. It uses the VST table _connect, to detect users that are connected remotely and lists them in a browser. To disconnect a user, select the user and press the "shut" button.
The sample code programs Cli_shut.p and Apps_shut.p are also attached in the file Remote_shut.zip

To implement disconnecting users from a client running on another machine:
 
1.   On the Server side put the program Apps_shut.p in a directory that is included in the PROPATH.
Replace the database name with the path and database you want to disconnect the users from.
/* App_shut.p program set the path and the database name to disconnect users from */

DEFINE INPUT PARAMETER shut_id AS INTEGER.
OS-COMMAND SILENT VALUE("proshut dbname -C disconnect " + TRIM(STRING(shut_id,">>>9"))).
MESSAGE "Remote proshut disconnecting user: " + TRIM(STRING(shut_id,">>>9")) .
RETURN.

2.   On the Client side, execute the following Cli_shut.p program:
 
   /* Cli_shut.p */
   /* This program will run on the client side and will browse the user list with the _Connect VST */
   /* If you press the shut button it will disconnect the selected user and exit*/

DEFINE VARIABLE shut_w AS WIDGET NO-UNDO.

DEFINE BUTTON but_shut LABEL "&Shut User".
DEFINE BUTTON but_exit LABEL "&Exit".
DEFINE BUTTON but_refr LABEL "&Refresh".

DEFINE VARIABLE servhdl AS HANDLE.
DEFINE VARIABLE ret AS LOGICAL.
DEFINE VARIABLE shut_db AS CHARACTER.
DEFINE VARIABLE shut_id AS INTEGER.

DEFINE QUERY shut_q FOR _Connect.
DEFINE BROWSE shut_b QUERY shut_q

DISPLAY 
_Connect._Connect-Usr
_Connect._Connect-Name
_Connect._Connect-Type
_Connect._Connect-Wait
_Connect._Connect-Wait1
_Connect._Connect-TransID
_Connect._Connect-PID
_Connect._Connect-Server
_Connect._Connect-Time
WITH 15 DOWN.

FORM shut_b
but_shut AT 1
but_refr AT 20
but_exit AT 110
WITH FRAME shut_f
1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1 SIZE 120 BY 14.50
CANCEL-BUTTON but_exit.

ON CHOOSE OF but_shut
DO:
IF AVAILABLE _Connect THEN DO TRANSACTION:
shut_id = _Connect._Connect-Usr.
CREATE SERVER servhdl.
ASSIGN ret = servhdl:CONNECT("-S 5162 -H localhost -AppService asbroker1").
IF ret THEN RUN apps_shut.p ON SERVER servhdl TRANSACTION DISTINCT (INPUT shut_id).
ASSIGN ret = servhdl:DISCONNECT().
DELETE OBJECT servhdl.
END.
END.

ON CHOOSE OF but_refr
DO:
RUN open_query IN THIS-PROCEDURE.
END.

CREATE WINDOW shut_w
ASSIGN
HEIGHT = 14.50
WIDTH = 120
STATUS-AREA = NO
MESSAGE-AREA = NO.

RUN open_query IN THIS-PROCEDURE.
VIEW FRAME shut_f IN WINDOW shut_w.
ENABLE ALL WITH FRAME shut_f.

APPLY "cursor-down" TO shut_b.

WAIT-FOR WINDOW-CLOSE OF shut_w OR CHOOSE OF but_exit FOCUS shut_b.
DELETE WIDGET shut_w.
QUIT.

PROCEDURE open_query:
OPEN QUERY shut_q FOR EACH _Connect WHERE _Connect._Connect-Type = "REMC".
END.
 

 

Workaround
Notes
Last Modified Date5/28/2021 11:10 PM
Attachment 
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.