You can use the IBM-supplied command RTVUSRPRF (Retrieve User Profile) to retrieve user profile information into a CL program. I’ve often used the command to determine what special authorities a user has. I knew that the command ONLY returned those special authorities found in the individual user profile and not those in any associated group profile. So, since individual user profiles inherit special authorities from their group profiles, to actually determine the user’s special authorities, I needed to also traverse the list of the user’s group profiles and check for special authorities in each group. It was not pretty.
The answer for fixing my ugly code comes in this issue of the newsletter in the new command CHKSPCAUT (Check Special Authorities), written by Carsten Flensburg.
The CHKSPCAUT command uses the IBM-supplied API QSYCUSRS (Check User Special Authorities), which returns not only those Special Authorities found in the User Profile, but also those found in any Associated Group Profile and any Adopted authority in effect at the time that the API is called.
You run the command by specifying the user ID and the special authorities that you’re looking for. If the requested special authorities aren’t found, the error message CPFB304 is returned to the initiating program. If the authorities are found, no message is generated, a la CHKOBJ (Check Object).