Identify users that have never logged in

Here's a CLP and a CMD that list all of the users who have never been logged and have been created for more than "N" days ago.

Here's a CLP and a CMD that list all of the users who have never been logged and have been created for more than "N" days ago. We create this due to the auditors. I hope you'll find them useful.

COMMAND XUSRCTL

CMD        PROMPT('Users never signed on')               
PARM       KWD(LIMIT) TYPE(*CHAR) LEN(5) DFT(60) +       
             REL(*GE 60) CHOICE('A number greater than + 
             59') PROMPT('Maximum number of allowed days')
PARM       KWD(MODE) TYPE(*CHAR) LEN(1) RSTD(*YES) +     
             DFT(T) VALUES(T V) PROMPT('(T)heorical +    
             (D)elete')                                  

CLP: XUSRCTLCPP

             PGM        PARM(&LIMITA &MODE)                
             DCLF       FILE(QTEMP/USER)                   
             DCL        VAR(&CRTDTA) TYPE(*CHAR) LEN(13)   
             DCL        VAR(&CRTYMD) TYPE(*CHAR) LEN(6)    
             DCL        VAR(&CRTDTAJUL) TYPE(*CHAR) LEN(6) 
             DCL        VAR(&TODAY) TYPE(*CHAR) LEN(6)     
             DCL        VAR(&TODAYJUL) TYPE(*CHAR) LEN(6)  
             DCL        VAR(&MODE) TYPE(*CHAR) LEN(1)      
             DCL        VAR(&LIMITA) TYPE(*CHAR) LEN(5)    
             DCL        VAR(&DELTAA) TYPE(*CHAR) LEN(5)    
                                                           
             DCL        VAR(&Y2) TYPE(*CHAR) LEN(2)        
             DCL        VAR(&D2) TYPE(*CHAR) LEN(3)        
             DCL        VAR(&Y1) TYPE(*CHAR) LEN(2)        
             DCL        VAR(&D1) TYPE(*CHAR) LEN(3)        
                                                           
             DCL        VAR(&Y2N) TYPE(*DEC) LEN(2 0)                 
             DCL        VAR(&D2N) TYPE(*DEC) LEN(3 0)                 
             DCL        VAR(&F2N) TYPE(*DEC) LEN(5 0)                 
             DCL        VAR(&Y1N) TYPE(*DEC) LEN(2 0)                 
             DCL        VAR(&D1N) TYPE(*DEC) LEN(3 0)                 
             DCL        VAR(&F1N) TYPE(*DEC) LEN(5 0)                 
             DCL        VAR(&DELTA) TYPE(*DEC) LEN(5 0)               
             DCL        VAR(&LIMIT) TYPE(*DEC) LEN(5 0)               
                                                                      
             CHGVAR     VAR(&LIMIT) VALUE(&LIMITA)                    
             IF         COND(&LIMIT < 60) THEN(CHGVAR VAR(&LIMIT) +   
                          VALUE(60))                                  
             DLTF       FILE(QTEMP/USER)                              
             MONMSG     MSGID(CPF2105)                                
             DSPUSRPRF  USRPRF(*ALL) OUTPUT(*OUTFILE) +               
                          OUTFILE(QTEMP/USER)                         
             RTVJOBA    DATE(&TODAY)                                  
             CVTDAT     DATE(&TODAY) TOVAR(&TODAYJUL) +                
                          FROMFMT(*SYSVAL) TOFMT(*JUL) TOSEP(*NONE)    
             CHGVAR     VAR(&Y2) VALUE(%SST(&TODAYJUL 1 2))            
             CHGVAR     VAR(&D2) VALUE(%SST(&TODAYJUL 3 3))            
             CHGVAR     VAR(&Y2N) VALUE(&Y2)                           
             CHGVAR     VAR(&D2N) VALUE(&D2)                           
             CHGVAR     VAR(&F2N) VALUE(&Y2N * 365)                    
             CHGVAR     VAR(&F2N) VALUE(&F2N + &D2N)                   
                                                                       
 READ:       RCVF                                                      
             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END))          
             IF         COND(&UPPSOD = '      ') THEN(DO)              
             RTVOBJD    OBJ(&UPUPRF) OBJTYPE(*USRPRF) CRTDATE(&CRTDTA) 
             CHGVAR     VAR(&CRTYMD) VALUE(%SST(&CRTDTA 2 6))          
             CVTDAT     DATE(&CRTYMD) TOVAR(&CRTDTAJUL) +              
                          FROMFMT(*YMD) TOFMT(*JUL) TOSEP(*NONE)       
                                                                       
             CHGVAR     VAR(&Y1) VALUE(%SST(&CRTDTAJUL 1 2))        
             CHGVAR     VAR(&D1) VALUE(%SST(&CRTDTAJUL 3 3))        
             CHGVAR     VAR(&Y1N) VALUE(&Y1)                        
             CHGVAR     VAR(&D1N) VALUE(&D1)                        
             CHGVAR     VAR(&F1N) VALUE(&Y1N * 365)                 
             CHGVAR     VAR(&F1N) VALUE(&F1N + &D1N)                
             CHGVAR     VAR(&DELTA) VALUE(&F2N - &F1N)              
             IF         COND(&DELTA < 0) THEN(CHGVAR VAR(&DELTA) +  
                          VALUE(99999))                             
             CHGVAR     VAR(&DELTAA) VALUE(&DELTA)                  
             MONMSG     MSGID(CPF0819) EXEC(CHGVAR VAR(&DELTA) +    
                          VALUE(99999))                             
                                                                    
             IF         COND(&DELTA > &LIMIT) THEN(DO)              
             IF         COND(&MODE = 'D') THEN(CHGUSRPRF +          
                          USRPRF(&UPUPRF) STATUS(*DISABLED))        
             IF         COND(&MODE *EQ 'D') THEN(SNDPGMMSG +        
                          MSG('User' *BCAT &UPUPRF *BCAT 'HAS BEEN + 
                          DISABLED by cmd XUSRCTL'))                 
             IF         COND(&MODE *NE 'D') THEN(SNDPGMMSG +         
                          MSG('User' *BCAT &UPUPRF *BCAT 'never +    
                          logged in, created' *BCAT &DELTAA *BCAT +  
                          'days ago'))                               
             ENDDO                                                   
                                                                     
             ENDDO                                                   
             GOTO       CMDLBL(READ)                                 
 END:        DSPJOBLOG  OUTPUT(*PRINT)                               
             ENDPGM                                                  

               
               

This was first published in February 2007

Dig deeper on iSeries system and application security

0 comments

Oldest 

Forgot Password?

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

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close