AS/400 how to tell if user signed on.

5 pts.
Tags:
AS/400 administration
WRKUSRJOB
I need to see if a user is signed onto the AS/400 before I send a break message to them, does anyone know of a clever way to do this. I know I could do it using WRKUSRJOB and then copying that spool file to a file, but I wondered if there was an easier way.

Answer Wiki

Thanks. We'll let you know when a new response is added.

For so many answers, you’d think at least one should work.

To determine if a user is “logged on”, you first have to define what you mean. A user who has connected through the Signon host server is “logged on” even if there is no telnet session. The same is true for ODBC and other functions. The *USRPF will then have a lock, so solutions such as testing for locks against the profile won’t help. And actually, testing locks will only tell you if a lock exists. Any job can lock anything that’s authorized.

Suggestions for 3rd-party tools are close to useless. They provide no information that helps answer the question of how to do it.

Most likely, what you want to know is whether a user has an active interactive job or not. Call the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/qusljob.htm”>List Job (QUSLJOB) API</a>. Supply the user name as part of the qualified job name with “*ALL” for job name and for number; request *ACTIVE job Status; and request only ‘I’nteractive Job type.

You don’t need to process any list returned from the API. All you need to do is check the number of list entries to see if it’s zero. If not, the user is active in an interactive session.

Just call the API and check the count.

If the List Jobs API seems difficult, you might prefer the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/QEZLSGNU.htm”>List Signed-On Users (QEZLSGNU) API</a>. It’s much more direct, but not as familiar to others. Any oddities that you run into might leave you on your own for a while.

Like List Jobs, all you really need is a non-zero count to know if the user is signed on.

Tom

========================================================

You could use this command:

WRKACTJOB

Then search for user’s name in the Qinter subsystem. If you see his / her userID, then that person is signed on.

TAATOOL RTVJOBSTS
JOB(&userid/*ALL) STATUS(*ACTIVE) RTNJOB(&JOBNAME)

This will return the first active job for user — it might not be interactive, however.
This will give you the data for the RTVJOBA command. But if this job is batch, how to find the next?

I think you will need TAATOOL DSPUSRJOB
DSPUSRJOB USER(&userid) STATUS(*ACTIVE) JOBTYPE(*INTERACT) OUTPUT(*Print)
Then use the spool file

Use the API QEZSNDMG

/*—————————————————————————————————–*/
/* PROGRAM: XYZBRKMSG */
/* DESCRIPTION: SEND */
/* A MESSAGE TO ANY USER USING THE QEZSNDMG API FROM */
/* THE OPERATIONAL ASSISTANT MENU. */
/* */
/* &MSGTEXT – 80 CHARACTER MESSAGE */
/* &USERID – 10 CHARACTER USERID TO RECEIVE MSG */
/* */
/* NOTES: -THE MESSAGE TEXT PASSED TO THIS PROGRAM */
/* SHOULD BE LIMITED TO 80 CHARS. */
/* */
/* SEND TO: */
/* USERID – INDIVIDUAL USERID */
/* *SYSOPR – SYSTEM OPERATOR */
/* *ALL – ALL USERS EVEN IF NOT SIGNED ON */
/* *ALLACT – ALL USERS SIGNED ON */
/* */
/* -IF THE USER HAS MULTIPLE SESSIONS OPEN, */
/* EACH SESSION WILL RECEIVE A MESSAGE. */
/*—————————————————————————————————-*/
XYZBRKMSG: PGM
DCL VAR(&MSGTYPE) TYPE(*CHAR) LEN(10) +
VALUE(‘*INFO’)
DCL VAR(&DELMODE) TYPE(*CHAR) LEN(10) +
VALUE(‘*BREAK’)
DCL VAR(&MSGTEXT) TYPE(*CHAR) LEN(80) +
VALUE(‘Please logoff – system backup +
about to commence’)
DCL VAR(&MSGLENG) TYPE(*CHAR) LEN(04) +
VALUE(X’00000050′)
DCL VAR(&USERID) TYPE(*CHAR) LEN(10) VALUE(*ALLACT)
DCL VAR(&USRCNT) TYPE(*CHAR) LEN(04) +
VALUE(X’00000001′)
DCL VAR(&MSGSENT) TYPE(*CHAR) LEN(04) +
VALUE(X’00000000′)
DCL VAR(&FUNCREQ) TYPE(*CHAR) LEN(04) +
VALUE(X’00000000′)
DCL VAR(&ERROR) TYPE(*CHAR) LEN(256) +
VALUE(X’00000100′)
DCL VAR(&SHOWMSG) TYPE(*CHAR) LEN(01) VALUE(‘N’)
DCL VAR(&REPLYMQ) TYPE(*CHAR) LEN(20)
DCL VAR(&NAMETYPE) TYPE(*CHAR) LEN(04) +
VALUE(‘*USR’)
CALL PGM(QEZSNDMG) PARM(&MSGTYPE &DELMODE +
&MSGTEXT &MSGLENG &USERID &USRCNT +
&MSGSENT &FUNCREQ &ERROR &SHOWMSG +
&REPLYMQ &NAMETYPE)
ENDPGM: ENDPGM

Discuss This Question: 10  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • WoodEngineer
    TAATools has a great commend - SNDBRKACT, which sends a break message to users who are logged on. I seem to remember that IBM has a native command that sends messages only to those signed on but I can not find it right now. I think it was just a parm on one of the message commands, not a separate command like SNDBRKACT. If your machine was delivered with the TAATOOLS library you probably have the command source for SNDBRKACT.
    6,295 pointsBadges:
    report
  • WoodEngineer
    Found it . . . but its not a break message. QSYS/SNDMSG MSG('This message only goes to active work stations') TOUSR(*ALLACT)
    6,295 pointsBadges:
    report
  • Adlerca
    Another easier way is to merely enter the cmd WRKUSRJOB xxxxx *ACTIVE Where xxxxx = user profile ID If user is logged on you will be presented with an active session. If user is not logged on, you will be presented with (No jobs to display)
    25 pointsBadges:
    report
  • 770
    API QWCLOBJL wil get You object locks. Specify User profile name, type *USRPRF, and check if there are any locks. if it is not locked, the user is not signed on.
    60 pointsBadges:
    report
  • Geekprime
    wrkactjob sbs(qinter) then place your cursor on the user column and press F16 (shift F4) this sorts by username, under subsystem/job it shows the name of the workstation, you can send a break message to the workstation. SNDBRKMSG MSG(this is a message) TOMSGQ(workstation name)
    275 pointsBadges:
    report
  • HunterP
    I don't think anyone really addressed the real question (at least how I read it), that is how to determine if a user is signed on from within a program. The questioner states that she could output the WRKUSRJOB command to a print file (since it doesn't allow *FILE as output) then CPYSPLF to a physical file, where it can be read by the program to determine if a user is signed on. All the answers I've read in this thread talk about how it could be actively done by a user, not a process or program. I'm in the process of trying to accomplish the same thing and do not want to try to read information from a spool file that's been copied to a flat file. It can be done, it just seems like a sloppy way to do it. Any thoughts out there on this dilemma?
    20 pointsBadges:
    report
  • HunterP
    I think I found a solution, if you have TAATOOL on your system; there is a command in TAATOOL, CVTWRKACT, which outputs WRKACTJOB to a file. Badda-bing, then you just need to check the user name field in the WRKACTP file which is created by this command, in the library of your choosing.
    20 pointsBadges:
    report
  • philpl1jb
    this will be buried in Sept 08 -- you might want to put a new request out. It still looks to me like you're here: WRKUSRJOB USER( userID ) STATUS(*ACTIVE) OUTPUT(*PRINT) JOBTYPE(*INTERACTIVE) To a flat file and read it into your RPG or CL program. Phil
    49,550 pointsBadges:
    report
  • Teandy
    You can do this with a combination of exit point QIBM_QWT_JOBNOTIFY and a couple of API's. Check out http://www.rpgiv.org/QBATCHLOG.htm. You should be able to modify the examples to do what you want.
    5,860 pointsBadges:
    report
  • Sloopy
    User profiles have message queues associated with them. These message queues, by default, are the same name as the user profile. In your program, having got the user ID, do this:
    ALCOBJ OBJ((&USER *MSGQ *EXCL)) WAIT(1)
    MONMSG CPF1000 EXEC(GOTO NOT_ON)
    DLCOBJ OBJ((&USER *MSGQ *EXCL))
    
    (your processing here)
    
    NOT_ON:
    
    (The program may have to be compiled to adopt owner authority, and to be owned by a profile with the correct authorites to be able to allocate and deallocate objects.) Regards, Sloopy
    2,195 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following