Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Active User Check

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Active User Check

    I have the requirement to be able to determine within a program (RPG or CL)if a given user is active on the system. Ideally, a utility program that could be passed a couple of variables, including userid, active(y/n) and possibly a variable for the number of active sessions a user has. The utility program would return the variables indicating if the user is active and how may sessions the user has open. Thank you, Pat Davis pdavis@rpdco.com

  • #2
    Active User Check

    Patrick, Don't know of a real 'neat' way of doing this but ---- You can do a WRKACTJOB OUTPUT(*PRINT) SBS(QINTER) then do a CPYSPLF of that file to a physical file you have created. Maybe just make it a PF with record length of 132. You could then read that file and pick out the records that are showing you which jobs are interactive (INT) and grab the user from the same record. You would have to determine the positions in 132 record length would tell you that, perhaps by putting the record into a data structure. Hope that helps Steve Peters

    Comment


    • #3
      Active User Check

      Patrick, You might want to look at the Open List of Jobs (QGYOLJOB) API. I have never used this API, but I have used several that are very similar. If you think it would do what you want I could probably help you with the list processing code which should give you a pretty good start. David Morris

      Comment


      • #4
        Active User Check

        You might want to consider WRKUSRJOB; you can specify the User ID. But there is no outfile for this command; Use the *PRINT option into a spool file.

        Comment


        • #5
          Active User Check

          Patrick, The List Signed-On Users (QEZLSGNU) API generates a list of signed-on users and places the list in the specified user space. You will find all the information that you are looking for. HTH

          Comment


          • #6
            Active User Check

            Patrick, If knowing the number of active sessions is a nicety instead of a necessity, try to do an exluclusive lock on the user's message queue. Retrieve the user's message queue with RTVUSRPRF and then use ALCOBJ *EXCL. If you get the lock, the user is not signed on. Make sure you release the lock too with DLCOBJ. I can't provide coding examples right now. Later. Chris

            Comment


            • #7
              Active User Check

              Patrick, Follow the advice about using the API's. The WRKACTJOB and WRKUSRJOB to *PRINT advice will yield incomplete or erroneous results. Remember that many of the server daemons jobs start under the user QTCP or QUSER, and then do a swap profile to the active user. WRKACTJOB and WRKUSRJOB will show you who started the job, but not who's authority the job is currently running under. For an example of what I am talking about, do a DSPJOB for several jobs in SBSD QSERVER and you'll see that there is an entry for "Current user". This is not always the same user as the user that started the job. jte

              Comment

              Working...
              X