15 pts.
 Need to write a CL program to track user logins
HI, I WANT HOW TO WRITE A CL PROGRAMME TO KNOW A USER IS LOGGED IN OR NOT.MEANS IN A SERVER NUMBER OF USERS OR THERE SO I WANT TO FIND OUT WHICH USER IS LOGIN STATE WHICH OR NOT LOG-OFF STATE.WHEN I RUN A PGM TO PROVIDE USER NAME IT WILL SHOW THE LOGIN OR LOGOFF STATUS...

Software/Hardware used:
ASKED: June 17, 2010  5:59 AM
UPDATED: July 3, 2010  6:01 AM

Answer Wiki:
Here are a couple of examples that you should be able to modify to fit your needs. http://forums.systeminetwork.com/isnetforums/showthread.php?t=49498 http://www.rpgiv.org/QBATCHLOG.htm
Last Wiki Answer Submitted:  June 19, 2013  2:07 pm  by  Teandy   5,860 pts.
All Answer Wiki Contributors:  Teandy   5,860 pts. , Chris Leonard   3,140 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Define “login”.

Do you want users who are logged into the *DATABASE server? The *DTAQ server? The *FILE server? FTP? Telnet? There are a lot of ways to “login” as a user.

Tom

 110,135 pts.

 

Note that QIBM_QWT_JOBNOTIFY reports when jobs start or end. Job starts do not indicate “logons” and job ends do not indicate “logoffs”.

Tom

 110,135 pts.

 

Note that QIBM_QWT_JOBNOTIFY reports when jobs start or end. Job starts do not indicate “logons” and job ends do not indicate “logoffs”.

Funny, I’ve been using it for just that purpose for a couple of years now and it works flawlessly.

 5,860 pts.

 

The audit journal should contain any information that need about job’s starting and ending. I created a report for a bank to show all users that signed on or off between the hours of 7:00 pm and 5:00 am using only the audit journal entry type ‘JS’. The audit journal entry type ‘JS’ includes Start, End, Job type, job name, user, and number, real user, effective user and LOTS of other parameters. There are over 30 fields of information about job changes in the JS audit journal entry.

Can you be more specific about what you are tyring to accomplish?

 325 pts.

 

…I’ve been using it for just that purpose for a couple of years now and it works flawlessly.

…As far as you know.

Granted, it is possible to have it work nearly flawlessly; but if it’s true for you, then you have an extremely atypical system and your method won’t work for most other systems.

You must:

  • ,,,nor run any host servers (or reject every logon attempt through them),
  • not run any TCP servers except telnet (or reject every logon through them)
  • don’t allow logons through Windows networking,
  • no DDM nor remote SQL,
  • no Management Central,
  • no iSeries Navigator,
  • strict menu security, so only green-screen processing with no or extremely limited command-line access and tight control over commands, eliminating group jobs and a couple others,
  • and all users running in QINTER.

It’s certainly possible, but I’d guess you’re close to unique.

If any of those are used, then your system is handing out logons and you’re missing them.

Tom

 110,135 pts.

 

thanks for all.But i have done this earliar.Using wrkactjob to generate spool file and copy that spool file into a database file using cpysplf command in cl propgramme.take the help of substring operation choos the user values………

 15 pts.

 

If that’s the only information that you needed from the system, it’s much better to after it directly. Here’s the source for a CHKUSRACT (Check User Active?) command:

 CHKUSRACT:  CMD        PROMPT('Check user active?')

             PARM       KWD(USRPRF) TYPE(*NAME) LEN(10) MIN(1) +
                          EXPR(*YES) PROMPT('User activity to check +
                          for')

Compile this CL as the command processing program:

pgm    ( +
         &pChkUsr      +
       )


   dcl   &pChkUsr       *char       10


   dcl   &usrspc        *char      10  VALUE( '#$CHKUSRAC' )
   dcl   &usrspclib     *char      10  VALUE( 'QTEMP     ' )

   dcl   &qusrspc       *char      20

   dcl   &us_hdr        *char     150   /* Space header      */


/* Number of list entries: Listed jobs...                           */

   dcl   &NbrLstE       *dec      (7)


/*  The qualified search job name...                                */
   dcl   &SchJob        *char     26


   chgvar    &qusrspc        ( &usrspc *cat &usrspclib )


/*  Create a usrspc to hold the job list data from this usrprf...   */

   call  QUSCRTUS         ( +
                            &qusrspc                +
                            'TMPLST    '            +
                            x'00001000'             +
                            X'00'                   +
                            '*ALL      '            +
                            'Temp list usr jobs     ' +
                            '*YES      '            +
                            x'0000000000000000'     +
                          )



/*                                                                  */
/*  Populate the usrspc with appropriate job list data...           */
/*                                                                  */

   chgvar    &SchJob         ( +
                               '*ALL      ' *cat         +
                               &pChkUsr     *cat         +
                               '*ALL      '              +
                             )

   call  QUSLJOB          ( +
                            &qusrspc                +
                            'JOBL0100'              +
                            &SchJob                 +
                            '*ACTIVE   '            +
                            x'0000000000000000'     +
                            'I'                     +
                            x'00000000'             +
                            x'00000000'             +
                          )


/*  Retrieve the header data...                                     */

   call  QUSRTVUS         ( +
                            &qusrspc                +
                            x'00000001'             +
                            x'00000096'             +
                            &us_hdr                 +
                          )

   chgvar    &NbrLstE        %bin( &us_hdr    133 4 )


   if ( &NbrLstE *eq 0 )  do
      sndpgmmsg  msgid( CPF9898 ) msgf( QCPFMSG ) +
                   msgdta( 'No active jobs found' )
   enddo

   else  if ( &NbrLstE *eq 1 )  do
      sndpgmmsg  msgid( CPF9898 ) msgf( QCPFMSG ) +
                   msgdta( 'Exactly one job found' )
   enddo

   else  +
      sndpgmmsg  msgid( CPF9898 ) msgf( QCPFMSG ) +
                   msgdta( 'Multiple jobs found' )


Clean_up:

   dltusrspc   &usrspclib/&usrspc

   return

endpgm

The command accepts a user profile name. The program asks the system for a list of *ACTIVE jobs for that user, restricting the list to ‘I’nteractive jobs only. When the list is returned, the number of list entries is extracted.

The number is tested for zero, 1 or more jobs, and a message is sent based on the result. Just be aware that the count isn’t a count of “logins”. The WRKACTJOB command won’t tell you about logins either, so it doesn’t matter.

Tom

 110,135 pts.