Once we know that a user-id and password as usable, and we've received a "profile handle" for them, we can use that profile handle to make the job "run under that user profile".
We do that by calling the Set Profile (QWTSETP) API. After this API has been called successfully, everything that new that we try to do will use the authority of the new user-id.
The Set Profile (QWTSETP) API is documented in the IBM manual at this location: http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/apis/QWTSETP.htm
The manual tells us that the API accepts these parameters:
Required Parameter Group: | |||
---|---|---|---|
1 | Profile handle | Input | Char(12) |
Optional parameter: | |||
2 | Error code | I/O | Char(*) |
The RPG prototype for this API will look like this:
D SetProfile PR ExtPgm('QWTSETP') D Handle 12A const D ErrorCode 32766A options(*varsize: *nopass)
And we'll call it like this:
c callp GetProfile(UserID: Passwd: Handle: c dsEC) c if dsECBytesA > 0 C** handle "invalid user profile" error c endif c callp SetProfile(Handle: dsEC) c if dsECBytesA > 0 C** handle "could not set profile" error C endif
Please add this prototype to your JOBINFO_H member, as well.
Or, if you prefer, you could download my copy of JOBINFO_H, available here: http://www.scottklement.com/rpg/socktut/qrpglesrc.jobinfo_h