Problem solve Get help with specific problems with your technologies, process and projects.

Using system APIs to retrieve and set encrypted user password

If you are maintaining multiple AS/400 boxes and have the same user ID in all the boxes, and if you want to have the user set his password in just one box and get reflected in all other boxes, this tip will be useful.

There are system APIs for retrieving and setting the encrypted user password.

You can use the API QSYRUPWD to retrieve the user password from the AS/400 box where the password is changed and use the API QSYSUPWD to set the password in the other AS/400s with the value retrieved from the previous API in the previous box.

Note:
These APIs are not thread safe. The User should have *ALLOBJ and *SECADM authority to use this API. The value for the encrypted password length must match that of the system value QPWDMAXLEN The FORMAT Parameter for the APIs is case sensitive and should always be UPPER CASE.

Note:
The QSYSUPWD API updates the following fields in the user profile:
The password expiration field is set to *NO.
The password change date field is updated.
The user profile change date is updated.

A wrapper program should be written to call the following program in lopp for all user IDs.


========
RTVPWD
========
FPWDDEF00UF  E           K        DISK                      A     
I              'QSYRUPWD'            C         QSYDHB             
 *                                                                
I*****************************************************************
I*Record structure for UPWD0100 format                            
I*****************************************************************
IQSYDJ       DS                                                   
I*                                             Qsy RUPWD UPWD0100 
I                                    B   1   40QSYDJB             
I*                                             Bytes Returned     
I                                    B   5   80QSYDJC             
I*                                             Bytes Available    
I                                        9  18 QSYDJD             
I*                                             Profile Name       
I                                       19 269 QSYDJF             
I*                                                                
I*                                    Varying length              
I            DS                                                   
I                                    B   1   40#LEN               
I                                        5  12 #FRMT              
I                                       13  22 #USER   
I                                       23  72 #ERRFL  
 ******************************************************
C           *ENTRY    PLIST                            
C                     PARM           USER              
 *                                                     
C                     MOVELUSER      #USER             
C                     Z-ADD250       #LEN              
C                     MOVEL'UPWD0100'#FRMT             
C                     MOVEL*BLANKS   #ERRFL            
 *                                                     
C                     CALL 'QSYRUPWD'                  
C                     PARM           QSYDJ             
C                     PARM           #LEN              
C                     PARM           #FRMT             
C                     PARM           #USER             
C                     PARM           #ERRFL            
 *                                                     
 *                                                     
C                     MOVEL#USER     USER              
 *                                                      
C           USER      CHAINPASS                 50      
C                     MOVELQSYDJF    PWD                
 *                                                      
C           *IN50     IFEQ '1'                          
C                     WRITEPASS                         
C                     ELSE                              
C                     UPDATPASS                         
C                     ENDIF                             
 *                                                      
 *                                                      
C                     SETON                     LR      

______________________________________________________________
______________________


THE FILE PWDDEF00 HAS 2 FIELDS. ONE IS 
USER ID AND THE OTHER ONE IS PASSWORD.

THIS FILE SHOULD BE TRANSFERRED TO THE OTHER AS/400 SYSTEM WHERE 
YOU WANT TO SET THE PASSWORD.

AND THE FOLLOWING PROGRAM SHOULD BE EXECUTED.

========
SETPWD
========

FPWDDEF00IF  E           K        DISK                            
 *****************************************************************
I              'QSYSUPWD'            C         QSYDKB             
I*****************************************************************
I*Record structure for UPWD0100 format                            
I*****************************************************************
IQSYDL       DS                                                   
I*                                             Qsy SYPWD UPWD0100 
I                                    B   1   40QSYDLB             
I*                                             Bytes Returned     
I                                    B   5   80QSYDLC             
I*                                             Bytes Available    
I                                        9  18 QSYDLD             
I*                                             Profile Name       
I                                       19 269 QSYDLF             
I*                                                                
I            DS                                                   
I                                        1  50 ERRCD              
I                                       51  58 #FRMT              
I*                                                                
I*                                    Varying length    
 *******************************************************
C           *ENTRY    PLIST                             
C                     PARM           USER   10          
 *                                                      
C           USER      CHAINPASS                 50      
 *                                                      
C           *IN50     IFEQ '0'                          
C                     MOVEL'UPWD0100'#FRMT              
C                     MOVELUSER      QSYDLD             
C                     MOVELPWD       QSYDLF             
C                     CALL 'QSYSUPWD'                   
C                     PARM           QSYDL              
C                     PARM           #FRMT              
C                     PARM           ERRCD              
C                     ENDIF                             
 *                                                      
C                     SETON                     LR 

This was last published in January 2001

Dig Deeper on Performance

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close