Skip to main content

1E 8.1 (on-premises)

Users.GetLoggedOnUsers

Module

Users

Method

GetLoggedOnUsers

Library

Core

Action

List the active (currently logged-on) user sessions.

Parameters

(None)

Return values

For each session:

  • Account (string): User name.

  • SessionId (string): Session ID.

  • SessionName (string): Session Name.

  • LogonTime (string): Logon time of the session. Only available for Windows Vista SP1 and later.

  • SessionState (string): The session state as defined by the WTS_CONNECTSTATE_CLASS enum. MS Windows hosts only.

  • RemoteSession (boolean): Whether or not the session is a remote session

  • RemoteIp (string): IP address of the client if the connection is remote (otherwise empty).

  • RemoteName (string): Hostname of the client if the connection is remote (otherwise empty). On MacOS only the IP address is available.

Example

@users = Users.GetLoggedOnUsers();
//get the home drive/path for each logged on user by running a command as each of them
@home =
    FOREACH @user IN @users DO
        NativeServices.RunCommand(CommandLine:"CMD /c ECHO %HOMEDRIVE%%HOMEPATH%",AsUser:@user.Account);
        SELECT usr.*, cmd.Output AS Home FROM @user usr, @@last cmd;
    DONE;

Platforms

  • Windows

  • Linux

  • MacOS

Notes