Claus_Jambrich_5663

Displaying logged on users

Discussion created by Claus_Jambrich_5663 on Oct 6, 2016
Latest reply on Nov 22, 2016 by Harald_Heidinger_152
Ever wanted to know which users are logged on at the moment without using the GUI / AWI?
E.g. you want to know if there are users logged in outside the allowed time, see screenshot:

18ou1lpeexs1.png

For MS SQL, this request looks like below:

SELECT
  AH.AH_Client AS "Client",
  OH.OH_Name   AS "Name",
  OH.OH_NAME   AS "User",
  CASE
    WHEN USR.USR_VALIDTIMEFROM IS NULL THEN '-'
    ELSE CONVERT(varchar(8), USR.USR_VALIDTIMEFROM, 108)
  END AS "Logon allowed from",
  CASE
    WHEN USR.USR_VALIDTIMETO IS NULL THEN '-'
    ELSE CONVERT(varchar(8), USR.USR_VALIDTIMETO, 108)
  END AS "to",
  CASE
    WHEN USR.USR_VALIDTIMEFROM IS NOT NULL AND
      CONVERT(time, CONVERT(varchar(8), CURRENT_TIMESTAMP, 108)) NOT BETWEEN
      CONVERT(time, CONVERT(varchar(8), USR.USR_VALIDTIMEFROM, 108))
      AND CONVERT(time, CONVERT(varchar(8), USR.USR_VALIDTIMETO, 108)) THEN 'Still loged in outsied allowed time'
    ELSE '-'
  END AS "Logon"
FROM AH,
     OH,
     USR
WHERE AH_SType = 'DIALOG'
AND AH_OType = 'USER'
AND AH.AH_TIMESTAMP4 IS NULL
AND AH.AH_OH_Idnr = oh.OH_Idnr
AND OH.OH_Idnr = usr.USR_OH_Idnr;

The output looks like:

        vt1soigafudb.png

As you see, User JAC/SUP is logged on. He is only allowed to log on between 00:01 and 12:00. But as he never logged out, he is still  (assume the current time is 14:00) logged in though his time is over.



Outcomes