A little exec:
/***********************************************************************
* query if user is valid *
***********************************************************************/
trace 'o'
parse upper arg
address command
logon. = ""
arg userid
/* check pun */
"PIPE CP DEFINE PUN 01D"
"PIPE CP SPOOL 01D TO " userid
sprc = rc
"PIPE CP DETACH 01D"
/* check link */
"PIPE CP LINK " userid
lnkrc = rc
/* q user */
"PIPE CP Q USER "userid" | STEM LOGON."
logrc = rc
fndrc = min(sprc,lnkrc)
/* determine userid status - LOGON.3 = DSC if disconnected, blank otherwise
*/
select
when fndrc = 0 then select
when logrc = 0 then found="VALID and Logged On "word(logon.1,3)
when logrc = 45 then found="VALID and Not Logged On"
otherwise nop
end
when fndrc = 53 then found="INVALID"
when fndrc = 22 then found="VALID and set to NOLOG"
otherwise nop
end
/* display userid status and exit with rc for calling program */
/* 0 = 0+0 = Valid and logged on */
/* 45 = 0+45 = Valid and Not logged on */
/* 67 = 22+45 = Valid and set to nolog */
/* 98 = 53+45 = Invalid userid */
say "UserID "userid" is "found
exit fndrc+logrc
This electronic transmission and any documents accompanying this electronic
transmission contain confidential information belonging to the sender. This
information may be legally privileged. The information is intended only for
the use of the individual or entity named above. If you are not the intended
recipient, you are hereby notified that any disclosure, copying, distribution,
or the taking of any action in reliance on or regarding the contents of this
electronically transmitted information is strictly prohibited.