Get Profile Handle (QSYGETPH) API
Required Parameter Group:
1 | User ID | Input | Char(10) |
2 | Password | Input | Char(*) |
3 | Profile handle | Output | Char(12) |
Optional Parameter Group 1:
4 | Error code | I/O | Char(*) |
Optional Parameter Group 2:
5 | Length of password | Input | Bin(4) |
6 | CCSID of password | Input | Bin(4) |
Default Public Authority: *USE
Threadsafe: Yes
The Get Profile Handle (QSYGETPH) API validates user IDs and passwords and creates a profile handle for use in jobs that run under more than one user profile. The profile handle is temporary; you can use it only in the job that created it.
The QSYGETPH API follows this process:
- Verifies that the user ID and password are correct. Incorrect passwords and
special cases are handled as follows:
- If the password is not correct, the incorrect password count is increased.
(The QMAXSIGN system value contains the maximum number of incorrect attempts to
sign on.) If the QMAXSGNACN system value is set to disable the user profile,
repeated attempts to validate an incorrect password disable the user ID. This
keeps applications from methodically determining user passwords.
- To obtain a profile handle for a profile that does not have a password,
specify *NOPWD, *NOPWDCHK or *NOPWDSTS for the password parameter.
You cannot obtain a profile handle for the following system-supplied user profiles:
QAUTPROF QDLFM QMSF QSNADS QTSTRQS QCLUMGT QDOC QNETSPLF QSPL QCOLSRV QDSNX QNFSANON QSPLJOB QDBSHR QFNC QNTP QSRVAGT QDBSHRDO QGATE QPEX QSYS QDFTOWN QLPAUTO QPM400 QTCP QDIRSRV QLPINSTALL QRJE QTFTP
- To obtain a profile handle for a profile that is disabled,
specify *NOPWDCHK for the password parameter.
- To obtain a profile handle when the password is expired,
specify *NOPWDCHK or *NOPWDSTS for the password parameter.
- If the password is not correct, the incorrect password count is increased.
(The QMAXSIGN system value contains the maximum number of incorrect attempts to
sign on.) If the QMAXSGNACN system value is set to disable the user profile,
repeated attempts to validate an incorrect password disable the user ID. This
keeps applications from methodically determining user passwords.
- Generates the profile handle, a 12-character random string designating the
user's authorities. This string, not the user's password, supplies the Set
Profile Handle (QWTSETP, QsySetProfileHandle) and the Release Profile Handle
(QSYRLSPH, QsyReleaseHandle) APIs.
The maximum number of profile handles that can be created is approximately 20,000 per job; after that, the space to store them is full. Message CPF22E6 is sent to the application, and QSYGETPH stops generating profile handles.
Be sure to keep track of the profile handles created in the calling application. If the application calls QSYGETPH twice with the same user profile and password, QSYGETPH returns two different profile handles. Either handle can be used, but generating and using just one is more efficient.
- Updates the last-used date for the user and group profiles.
- Resets the signon attempts not valid count to zero.
- If security-related events are being audited, adds an entry to the QAUDJRN audit journal to indicate that a profile handle is created.
Authorities and Locks
- API Public Authority
- *USE
- User profile authority, if the password is *NOPWD, *NOPWDCHK or *NOPWDSTS.
- *USE
- User Profile Lock
- *LSRD
Required Parameter Group
- User ID
- INPUT; CHAR(10)
The user ID of the profile for which the handle is being created. A user ID must be a 10 character, blank padded value in CCSID 37.
You can specify the following special value:
*CURRENT A handle is generated with the current thread information. When specifying *CURRENT, password is ignored and length of password and CCSID of password are not allowed.
- Password
- INPUT; CHAR(*)
The password for the user ID or a special value.
Password for the user ID
- Length of password and CCSID of password are required
Special value
- Length of password and CCSID of password are not allowed when specifying a special value.
- A special value must be a 10 character, blank padded value in CCSID 37.
- Special values allowed are:
*NOPWD The user requesting the profile handle must have *USE authority to the user profile. A profile handle does not get created for a disabled user profile.
A profile handle does not get created for a user profile with an expired password.
*NOPWDCHK The user requesting the profile handle must have *USE authority to the user profile. If the profile is disabled, the user requesting the profile handle must have *ALLOBJ and *SECADM special authorities to get a handle.
If the password is expired, the user requesting the profile handle must have *ALLOBJ and *SECADM special authorities to get a handle.
*NOPWDSTS The user requesting the profile handle must have *USE authority to the user profile. A profile handle does not get created for a disabled user profile.
If the password is expired, the user requesting the profile handle must have *ALLOBJ and *SECADM special authorities to get a handle.
- Profile handle
- OUTPUT; CHAR(12)
A unique string or handle designating the user profile to use as input to other routines. The handle is temporary; you can use it only in the job that created it.
Optional Parameter Group 1
This parameter group is required when specifying a password for the password parameter. It is optional when specifying a special value.
- Error code
- I/O; CHAR(*)
The structure in which to return error information. For the format of the structure, see Error code parameter.
Optional Parameter Group 2
This parameter group is required when specifying a password for the password parameter. It is not allowed when specifying a special value.
- Length of password
- INPUT; BINARY(4)
The length, in bytes, of the password contained in the user profile password parameter.
The valid values are:
1-512 The length of the password in the password parameter. - CCSID of password
- INPUT; BINARY(4)
The CCSID of the password parameter. For a list of valid CCSIDs, see the IBM i globalization topic collection.
The valid values are:
-1 The current password level for the system is used to determine the CCSID of the password data. When calling this API on password level 0 or 1, CCSID 37 is used. When calling this API on password level 2 or 3, the default CCSID (DFTCCSID) job attribute is used. See usage notes for more details. 0 The CCSID of the job is used to determine the CCSID of the data to be converted. If the job CCSID is 65535, the CCSID from the default CCSID (DFTCCSID) job attribute is used. 1-65533 A valid CCSID in this range.
Usage Notes
Profile handles are a limited resource; it is possible to run out of handles. To guarantee that you always have a profile handle to switch back to, it is recommended that you get a profile handle for both the current thread and the user profile to which you plan to switch. If for some reason you cannot do this, and if you cannot get a profile handle that will allow you to switch back, then it probably is safest to end the thread or job.
The CCSID parameter on this API can lead to potential problems if coded with inconsistent CCSID values. Passwords created using the CRTUSRPRF, CHGUSRPRF, and CHGPWD CL commands, as well as the QSYCHGPW API (when called without passing the CCSID parameter), while the system is running password level 0 or 1 are created using CCSID 37. Passwords created using these CL commands and the QSYCHGPW API (without the CCSID parameter specified) when running password level 2 or 3 are created using the default job CCSID. Using variant characters $, @ and #, as well as other variant characters, in a user password may result in inconsistencies when converting from one CCSID to another. When calling this API on password level 0 or 1, CCSID 37 should be specified unless the password string is in a known CCSID. When calling this API on password level 2 or 3, pass the default job CCSID unless the password string is in a known CCSID.
Error Messages
Message ID | Error Message Text |
---|---|
CPF2203 E | User profile &1 not correct. |
CPF2204 E | User profile &1 not found. |
CPF2213 E | Not able to allocate user profile &1. |
CPF2225 E | Not able to allocate internal system object. |
CPF22E2 E | Password not correct for user profile &1. |
CPF22E3 E | User profile &1 is disabled. |
CPF22E4 E | Password for user profile &1 has expired. |
CPF22E5 E | No password associated with user profile &1. |
CPF22E6 E | Maximum number of profile handles have been generated. |
CPF22E9 E | *USE authority to user profile &1 required. |
CPF24B4 E | Severe error while addressing parameter list. |
CPF3BC7 E | CCSID &1 outside of valid range. |
CPF3BDE E | CCSID &1 not supported by API. |
CPF3C1D E | Length specified in parameter &1 not valid. |
CPF3C3C E | Value for parameter &1 not valid. |
CPF3C36 E | Number of parameters, &1, entered for this API was not valid. |
CPF3C90 E | Literal value cannot be changed. |
CPF3CF1 E | Error code parameter not valid. |
CPF4AB8 E | Insufficient authority for user profile &1. |
CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
API introduced: V2R1
[ Back to top | Security APIs | APIs by category ]