The API Corner: Re-enable Disabled User Profiles

APIs
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Learn more ways to use exit programs for the Watch for Event exit point.

                                                               

This is the third in a series of articles on watching for certain messages on your system and then making processing decisions based on those messages. The underlying technology being used is known as "watch" support and became available with V5R4.

 

The first article, "One Approach to System Automation," introduced the Start Watch (STRWCH) command and provided the source for a user exit program to run when the local system time changed due to Daylight Saving Time transitions. The second article, "Handling System Changes Automatically," discussed how the user exit program worked. If you have not read those two articles, you should do so before reading this article.

 

In this article, we will look at how to automate the re-enabling of a specific *USRPRF when the *USRPRF has been disabled because of too many invalid password attempts--that is, the number of signon attempts has exceeded the QMAXSIGN system value. In this situation, the system will send the message CPF1393 to the QSYSOPR and QHST message queues.

 

One watch-based approach to handle this situation is shown in the following user exit program, WCHCPF1393. The intent of this program is to determine whether the disabled user profile is 'GLAND' (George Land if you will) and, if so, to automatically re-enable the *USRPRF. If the *USRPRF is not 'GLAND', nothing is done--no message, no re-enablement, no anything.

 

dWchCPF1393       pr                  extpgm('WCHCPF1393')        

d Type                          10    const                       

d SsnID                         10    const                       

d Error                         10                                

d MsgDta                              likeds(ESCQWFM)             

                                                                  

dWchCPF1393       pi                                              

d Type                          10    const                       

d SsnID                         10    const                       

d Error                         10                                

d MsgDta                              likeds(ESCQWFM)             

                                                                   

dCmdExc           pr                  extpgm('QCMDEXC')           

d Command                    65535    const                       

d LenCmd                        15  5 const                       

d IGC                            3    const options(*nopass)      

                                                                     

 /copy qsysinc/qrpglesrc,escwcht                                     

                                                                     

dCPF1393          ds                  based(RplDtaPtr)               

d                                     qualified                      

d SbsD                          10                                   

d UsrPrf                        10                                    

d DevD                          10                                   

d NtwAddr                       45                                   

                                                                     

dRplDtaPtr        s               *                                  

dCommand          s            256                                   

                                                                     

dRqdNbrParms      c                   4                              

dSessionName      c                   'ENB_GLAND '                   

                                                                     

 /free                                                               

  monitor;           

                                                                                         

  // Check to make sure program environment is as expected          

  if %parms < RqdNbrParms;                                          

     dsply ('WCHCPF1393 received only ' + %char(%parms) + ' parms'); 

     *inlr = *on;                                                   

     return;                                                        

  endif;                                                            

                                                                     

  if Type <> '*MSGID';                                              

     dsply ('WCHCPF1393 received type ' + Type);                    

     Error = '*ERROR';                                               

     *inlr = *on;                                                   

     return;                                                        

  endif;                                                            

                                                                     

  if SsnID <> SessionName;                                          

     dsply ('WCHCPF1393 received SsnID ' + SsnID);                  

     Error = '*ERROR';                                              

     *inlr = *on;                                                   

     return;                                                        

  endif;                                                            

                                                                     

  if MsgDta.ESCMID00 <> 'CPF1393';                                  

     dsply ('WCHCPF1393 received message ' + MsgDta.ESCMID00);      

     Error = '*ERROR';                                              

     *inlr = *on;                                                    

     return;                                                        

  endif;                                                            

                                                                    

  // Everything looks OK so get message replacement data            

  RplDtaPtr = %addr(MsgDta) + MsgDta.ESCORD;                        

                                                                    

  // If *USRPRF is GLAND then re-enable                              

  if CPF1393.UsrPrf = 'GLAND';                                      

     Command = 'CHGUSRPRF USRPRF(' + %trimr(CPF1393.UsrPrf) +      

               ') STATUS(*ENABLED)';                               

     CmdExc(Command :%len(%trimr(Command)));                       

  endif;                                                           

                                                                   

  // Set normal end of processing                                  

  Error = *blanks;                                                 

  return;     

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$