/* REXX program using QSYGETPH and QWTSETP security APIs */ /* to switch to another user profile. */ /* Copyright by Shalom Carmel, 2007 */ /* Define variables for API */ parse upper arg New_Usr New_Pwd Handle = 'xxxxxxxxxxxx' PwdLen = length(New_Pwd) XPwdLen = 'X'||''''||copies('0',8-length(d2x(PwdLen)))||d2x(PwdLen)||'''' XPwdCCSID= 'X''00000000''' Old_Usr = '*CURRENT' Old_Pwd = 'xxxxxxxx' OldHandle = 'xxxxxxxxxxxx' ErrDS = copies(' ',500) CommandToExecute = "'call qcmd'" /* Execute API -switched user */ /* must not pass password length and codepage when using special values */ select when New_Pwd='*NOPWD' | New_Pwd='*NOPWDCHK' | New_Pwd='*NOPWDSTS' then do New_Pwd = ''''||New_Pwd||copies(' ',10-length(New_Pwd)) ||'''' 'CALL QSYGETPH ('New_Usr New_Pwd ' &Handle &ErrDS )' end otherwise do 'CALL QSYGETPH ('New_Usr New_Pwd ' &Handle &ErrDS ' XPwdLen XPwdCCSID ')' end end /* end select */ /* Execute API - original user */ 'CALL QSYGETPH ('Old_Usr Old_Pwd ' &OldHandle &ErrDS )' 'CALL QWTSETP (&Handle) ' interpret CommandToExecute 'CALL QWTSETP (&OldHandle) ' signal on error name Error_Trap exit /* Error Trapping Routine */ Error_Trap: interpret 'signal ' end_of_op