A Plex client application connects to the IBMi via the Plex Dispatcher. The user to make the connection is specified either in the .INI (WinC) or obclient.properties file. The dispatcher creates a job in the IBMi named YOBSYTCPCT which is run under the mentioned user profile.
Client is using a generic user id in their .INI and obclient.properties file, but when they get connected they want to be able to change that user profile to a different one.
Is this possible?
CA Plex 7.2.1 and 7.3
Below is a possible solution to change the user profile for the running job (e.g. YOBSYTCPCT):
1. Create a source code object with the below mentioned source code.
2. Create a RPGIV function that makes an API CALL to the source code object created in Step #1.
3. In Client function, once the Client connection established to System-I dispatcher, call the function created in Step #2.
Note: On successful client function connection made to System-I dispatcher, in case of the YOBSYTCPDP dispatcher, a new process YOBSYTCPCT is started for the client.
Calling the above mentioned function as defined, will change the 'Current user of YOBSYTCPCT' job to the provided user profile as provided (hardcoded value - nUserId, nPassword) in source code object, better parameterized.
As part of this solution, IBMi API QSYGETPH (Get Profile Handle) and QWTSETP (Set Profile Handle) are being used (please refer to the IBMi help for more details)
Source code snippet referred to in Step #1
Note: The code provided below is for demonstration purposes and not thoroughly validated.
--------------------------
h dftactgrp(*NO) bnddir('QC2LE') d GetUserProfile PR ExtPgm('QSYGETPH') d $userID 10A const d $password 10A const d $handle 12A d $errorCode 32766A options(*varsize: *nopass) d $length 10I 0 const options(*nopass) d $ccsid 10I 0 const options(*nopass) d SetUserProfile PR ExtPgm('QWTSETP') d $handle 12A const d $errorCode 32766A options(*varsize: *nopass) d ErrorDS DS d $bytesPrv 1 4I 0 INZ(256) d $bytesAvl 5 8I 0 INZ(0) d $errMsgID 9 15 d $reserved 16 16 d $errMsgDta 17 256 d curHandle s 12a d newHandle s 12a d nUserId s 10a inz('newuser') d nPassword s 10a inz('newuser-password') d length s 4B 0 inz(10) d ccsid s 4B 0 inz(37) /free //Get new user's profile handle. GetUserprofile(nUserId: nPassword: newHandle: ErrorDS: length: ccsid); if $bytesAvl > 0; //error else; //Switch to new user profile. SetUserProfile(newHandle: ErrorDs); if $bytesAvl > 0; //error else; Dsply 'Success'; //If required, set the user profile back to the original user. //SetUserProfile(curHandle: ErrorDs); if $bytesAvl > 0; //error endif; endif; endif; /end-free
--------------------------