The API Corner: Re-enable Disabled User Profiles PDF Print E-mail
Programming - APIs
Written by Bruce Vining   
Monday, 13 April 2009 19:00

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;     


Bruce Vining
About the Author:

Bruce Vining is president and co-founder of Bruce Vining Services, L.L.C., a firm providing contract programming and consulting services to the System i community (www.brucevining.com). He began his career in1979 as an IBM Systems Engineer in St. Louis, Missouri, and then transferred to Rochester, Minnesota, in 1985, where he continues to reside. From 1992 until leaving IBM in 2007, Bruce was a member of the System Design Control Group responsible for OS/400 and i5/OS areas such as System APIs, Globalization, and Software Serviceability. He is also the designer of Control Language for Files (CLF).

 

A frequent speaker and writer, Bruce can be reached at bvining@brucevining.com.

 

MC Press books written by Bruce Vining available now on the MC Press Bookstore.

 

IBM System i APIs at Work IBM System i APIs at Work

Master APIs with this in-depth, example-rich exploration into these powerful tools.

List Price $89.95
Now On Sale
 
Read More >>
Last Updated on Thursday, 28 May 2009 22:44
 

You must be logged in to view or make comments on this article.


User Rating: / 0
PoorBest 

   MC-STORE.COM