Page 1 of 1

RDMLX Userid associated with host task- change

Posted: Thu Aug 08, 2013 12:48 am
by jimoreilly
From the examples I understand that you can validate the Userid and Password of the current transaction by asking the user for those fields and calling the 3G program to check. But the component on the host still runs under the general userid associated with the partition, like a Lansa Web program. If we wish to run batch programs under specific userids, or use functions like SNDMSG it would be very helpful to be able to make the host task assume the validated userid/password. Is there any methods available to make this happen?

Re: RDMLX Userid associated with host task- change

Posted: Sat Apr 12, 2014 7:42 am
by dhnaigles
Look at the RDML code of function UFU001 (VLF Web IIP for Logon). This should do what you want.

Re: RDMLX Userid associated with host task- change

Posted: Mon Apr 14, 2014 8:46 am
by MarkDuignan
This CL program is shipped with LongRange for RPG - but it is equally usable in RDMLX.

It can validate a user profile and password and optionally change the current job to run as the user profile specified.

RDMLX code is stateless - so you probably need slight variation made in the this CL program.
When it is called to change the job to the user it should check what the current job user is and only change it if required.
In RDMLX his program needs to be called on every interaction - because RDMLX programs run in a stateless environment.

I would also tend to not call it 'CheckUser' - so much as 'ConfigureJob' - as there may be other things you want it to do later (eg: set the user's output queue).

Code: Select all

/*<<DES>>=Building block CHECKUSER CL program                                         */       
     /*<<KEY>>=buildingblock build block skeletons templates                               */       
     /*<<KEY>>=user validation authority userprofiles passwords                            */       
     /*<<CRT>>=T                                                                           */       
     /*<<URL>>=6                                                                           */       
     /*<<END>>                                                                             */       
             PGM        PARM(&USERPROF &PASSWORD &CHANGEJOB &RETCODE &ERRORMSG)                     
                                                                                                    
   /********************************************************/                                       
   /* Check that the passed User Id and Password are valid */                                       
   /* Status Codes Returned :                              */                                       
   /* OK = USER OK                                         */                                       
   /* IU = INVALID USER ID                                 */                                       
   /* IP = INVALID PASSWORD                                */                                       
   /* EX = PASSWORD EXPIRED                                */                                       
   /* UD = USER PROFILE DISABLED                           */                                       
   /* ER = UNEXPECTED ERROR                                */                                       
   /********************************************************/                                       
                                                                                                    
   /* Received Parms */                                                                             
             DCL        VAR(&USERPROF) TYPE(*CHAR) LEN(10)                                          
             DCL        VAR(&PASSWORD) TYPE(*CHAR) LEN(128)                                         
             DCL        VAR(&CHANGEJOB) TYPE(*CHAR) LEN(1)                                          
                                                                                                    
   /* Returned Parms */                                                                             
             DCL        VAR(&RETCODE) TYPE(*CHAR) LEN(2)                                            
             DCL        VAR(&ERRORMSG) TYPE(*CHAR) LEN(132)                                         
             DCL        VAR(&HANDLE) TYPE(*CHAR) LEN(12)                                            
             DCL        VAR(&RTNVAR) TYPE(*CHAR) LEN(8) VALUE(X'0000000000000000')                  
                                                                                                    
   /* Check User and Password for OS/400 V5R3 onwards */                                            
             CALL       PGM(QSYGETPH) PARM(&USERPROF &PASSWORD &HANDLE &RTNVAR X'00000080' +        
                          X'00000000')                                                              
                                                                                                    
   /* Invalid User                                             */                                   
             MONMSG     MSGID(CPF2203 CPF2204) EXEC(DO)                                             
                CHGVAR     VAR(&RETCODE) VALUE('IU')                                                
                CHGVAR     VAR(&ERRORMSG) VALUE('Invalid or unknown user profile.')                 
                GOTO       CMDLBL(END)                                                              
             ENDDO                                                                                  
                                                                                                    
   /* Unable to check this user                               */                                    
             MONMSG     MSGID(CPF22E9 CPF2213 CPF2217 CPF4AB8) EXEC(DO)                             
                CHGVAR     VAR(&RETCODE) VALUE('UV')                                                
                CHGVAR     VAR(&ERRORMSG) VALUE('Unable to access user profile details.')           
                GOTO       CMDLBL(END)                                                              
             ENDDO                                                                                  
                                                                                                    
   /* Password is invalid */                                                                        
             MONMSG     MSGID(CPF22E2) EXEC(DO)                                                     
                CHGVAR     VAR(&RETCODE) VALUE('IP')                                                
                CHGVAR     VAR(&ERRORMSG) VALUE('Invalid password.')                                
                GOTO       CMDLBL(END)                                                              
             ENDDO                                                                                  
                                                                                                    
   /* This profile has no password */                                                               
             MONMSG     MSGID(CPF22E5) EXEC(DO)                                                     
                CHGVAR     VAR(&RETCODE) VALUE('NO')                                                
                CHGVAR     VAR(&ERRORMSG) VALUE('No Password exists for this user.')                
                GOTO       CMDLBL(END)                                                              
             ENDDO                                                                                  
                                                                                                    
   /* Profile is disabled */                                                                        
             MONMSG     MSGID(CPF22E3) EXEC(DO)                                                     
                CHGVAR     VAR(&RETCODE) VALUE('UD')                                                
                CHGVAR     VAR(&ERRORMSG) VALUE('User Profile is disabled.')                        
                GOTO       CMDLBL(END)                                                              
             ENDDO                                                                                  
                                                                                                    
   /* Password has expired */                                                                       
             MONMSG     MSGID(CPF22E4) EXEC(DO)                                                     
                CHGVAR     VAR(&RETCODE) VALUE('EX')                                                
                CHGVAR     VAR(&ERRORMSG) VALUE('The password has expired.')                        
                GOTO       CMDLBL(END)                                                              
             ENDDO                                                                                  
                                                                                                    
   /* Unspecified error */                                                                          
             MONMSG     MSGID(MCH0000 CPF0000) EXEC(DO)                                             
                CHGVAR     VAR(&RETCODE) VALUE('ER')                                                
                CHGVAR     VAR(&ERRORMSG) VALUE('No error message available')                       
                RCVMSG     MSG(&ERRORMSG)                                                           
                MONMSG     MSGID(MCH0000 CPF0000)                                                   
                GOTO       CMDLBL(END)                                                              
             ENDDO                                                                                  
                                                                                                    
                                                                                                    
   /*    No error so far so swap job to be that user      */                                        
   /*    noting that this user must follow the same       */                                        
   /*    'no interuptions' rule as other LongRange        */                                        
   /*    user profiles do - no break messages, no         */                                        
   /*    password change prompts - nothing that interupts */                                        
   /*    the expected 5250 stream                         */                                        
                                                                                                    
             IF         COND(&CHANGEJOB = 'Y') THEN(DO)                                             
                                                                                                    
                CHGVAR     VAR(&RTNVAR) VALUE(X'0000000000000000')                                  
                                                                                                    
                CALL       PGM(QWTSETP) PARM(&HANDLE &RTNVAR)                                       
                                                                                                    
                MONMSG     MSGID(MCH0000 CPF0000) EXEC(DO)                                          
                   CHGVAR     VAR(&RETCODE) VALUE('ER')                                             
                   CHGVAR     VAR(&ERRORMSG) VALUE('No error message available')                    
                   RCVMSG     MSG(&ERRORMSG)                                                        
                   MONMSG     MSGID(MCH0000 CPF0000)                                                
                   GOTO       CMDLBL(END)                                                           
                ENDDO                                                                               
                                                                                                    
             ENDDO                                                                                  
                                                                                                    
   /* No error at all if we reach this point in the code */                                         
                                                                                                    
             CHGVAR     VAR(&RETCODE)  VALUE('OK')                                                  
             CHGVAR     VAR(&ERRORMSG) VALUE(' ')                                                   
                                                                                                    
   /* End the program */                                                                            
                                                                                                    
END:         ENDPGM