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;     

Bruce Vining

Bruce Vining is president and co-founder of Bruce Vining Services, LLC, a firm providing contract programming and consulting services to the System i community. He began his career in 1979 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 This email address is being protected from spambots. You need JavaScript enabled to view it.. 


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
Leverage the power of APIs with this definitive resource.
List Price $89.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: