Brief: Group profiles can reduce the amount of authorization assignments you need to manage. But, OS/400 only supports one group profile assignment per user. When a user needs to run a job under a different group profile, several steps are required including signing off. Now, with the command presented in this article, you can change the group profile for a job in one step-without compromising system security.
Many AS/400 installations use group profiles to simplify security management. User authorization can be assigned once for the group profile rather than repeating the authorization for each member of the group. Group profiles address many security management issues, but I frequently encounter one issue that cannot be solved with standard methods. In the business world, users often belong to different groups for different tasks. For example, in a small company, some people in the Order Entry department may also be responsible for Accounts Payable. Software packages sometimes require that users belong to a specific group profile regardless of their other functions.
AS/400 security restricts a user profile to a single group profile and it does not allow a group profile to be a member of another group. The technique most often used to get around this limitation involves assigning each person multiple user profiles with different group profiles. Unfortunately, this solution forces the user to sign on multiple times-once for each job function.
In an alternative method, you dynamically change the user's group profile for specific tasks, as this article explains. This technique eliminates the requirement for any user to have more than one user profile. Chances are good that it will improve your overall security since users are given additional authority only for the specific tasks that require that authority.
Group Profiles
As you create individual user profiles, you assign them membership in a group by naming a group profile in the GRPPRF parameter. For example, the command used to create user profile GLOOP as a member of group profile GRP1 is:
CRTUSRPRF USRPRF(GLOOP) + PASSWORD(--) GRPPRF(GRP1) + OWNER(*GRPPRF)
If user GLOOP needs to be associated with a second group profile-GRP2, for instance-the security officer could write a program that adopts the required authority and changes the group profile:
PGM CHGUSRPRF USRPRF(GLOOP) + GRPPRF(GRP2) ENDPGM
You might expect that a user could sign on with group profile GRP1 and then run this program to change to the second group, GRP2. This will not work because the currently active job for the user does not reflect the change. OS/400 establishes group profiles at sign-on, and changing the group profile for a user profile does not take effect until a new job starts. A user could change his group profile, sign off and sign on again each time he needs to change group profiles, but this is not an improvement over assigning multiple profiles to the same person.
To solve this problem, I wrote the Set Group Profile (SETGRPPRF) command shown in 1. This utility eliminates the need to sign on and off to change group profiles. The utility takes advantage of the security application program interfaces (APIs). The intended use of these APIs is to allow a server job to handle several users by dynamically changing the user profile associated with a job. The same APIs can also be used to dynamically change the group profile for a job without changing the user profile for the job. Program GRP004CL (2) includes a call to the APIs after the group profile has been changed. The APIs change the active group profile for the job.
To solve this problem, I wrote the Set Group Profile (SETGRPPRF) command shown in Figure 1. This utility eliminates the need to sign on and off to change group profiles. The utility takes advantage of the security application program interfaces (APIs). The intended use of these APIs is to allow a server job to handle several users by dynamically changing the user profile associated with a job. The same APIs can also be used to dynamically change the group profile for a job without changing the user profile for the job. Program GRP004CL (Figure 2) includes a call to the APIs after the group profile has been changed. The APIs change the active group profile for the job.
Those of you who are careful about security may be concerned that a user could use this program that adopts *ALLOBJ and *SEC-ADM access to use any group profile. This program poses no threat to security because the AS/400 doesn't allow use of a group profile unless the user has *OBJMGT and *CHANGE access to the profile. Adopted authority is ignored during the authority check to see if the user is authorized to the group profile. This allows the security officer to control the group profiles a user can activate. The following command grants user ELLEN the required authority to swap to the GRPSALES group profile.
GRTOBJAUT OBJ(GRPSALES) + OBJTYPE(*USRPRF) + USER(ELLEN) AUT(*OBJOPR + *OBJMGT *READ *DLT *ADD *UPD)
After this command executes, ELLEN can run SETGRPPRF to switch to the GRPSALES group profile; but she cannot select any other group profile. Group profile swapping is fast and requires less overhead than a sign-off and sign-on.
Group Jobs
The SETGRPPRF command is particularly useful in conjunction with group jobs. Group jobs allow a user to have up to 16 sessions from a single workstation. The Attention key is frequently used to display a menu of group jobs and to allow the user to switch between jobs. One potential use of group jobs and the dynmamic change of group profiles is to start a different group job for each different application that requires a unique group profile. When a group job is started, SETGRPPRF can set the appropriate group profile for the requested application. The user can press the Attention key to switch between group jobs, and each group job can have a different group profile. The group profile only needs to be set once when the group job is started.
Limitation with Batch Jobs
Any batch jobs that you submit after switching group profiles will be started using the group profile specified in the user profile at the time the batch job starts. The batch job may require a different group profile, so you must include a dynamic change of the group profile in the batch job or submit the batch job to run under a different user profile that has the correct group profile.
How the Utility Works
Now that you're sold on the usefulness of the SETGRPPRF utility (or even if you want a little more background before you decide to implement it), you're probably interested in the mechanics behind the operation. The standard error- handler code monitors messages and forwards them to the caller. The key logic for this program is highlighted to distinguish it from the error-handling code.
The program must adopt the authority of a user who has *ALLOBJ and *SECADM special authority. This access is required to change the user profile and to get a profile handle without providing a password. (A handle is a temporary value used to pass the identification of an object between two APIs).
The GRP004CL program changes the user profile to the new group profile, but has the side effect of revoking access to the original group profile. The program then grants the authority revoked by the CHGUSRPRF, so the user can switch back to his original group profile.
The Get Profile Handle (QSYGETPH) API gets the required profile handle needed to swap profiles. The *NOPWD option requires that the user have *ALLOBJ and *SECADM special authority.
The Set Profile (QWTSETP) API changes the job to run under the new group profile. The user profile is changed back to the original group, but the active group profile for the job will be the new group profile.
When the group profile for a user is changed back to the original group profile, there is a side effect of revoking access to the new group profile. The program then grants the authority revoked by the CHGUSRPRF, so the user can swap to the new group profile in the future.
The Net Results
The Set Group Profile utility can change the group profile for a job and eliminate the need for users to have multiple user profiles. This utility can also be used to select the appropriate profile based on the application the user intends to run, which improves usability and reduces the number of user profiles on the system.
Wayne O. Evans is an AS/400 security consultant and a frequent speaker on security topics. During his 27 years with IBM Corporation, he was involved with AS/400 security design issues.
Dynamic Change of Group Profile
Figure 1 Command SETGRPPRF
/*===============================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/SETGRPPRF) PGM(XXX/GRP004CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*===============================================================*/ SETGRPPRF: CMD PROMPT('Set Group Profile') PARM KWD(GRPPRF) TYPE(*NAME) LEN(10) MIN(1) + PROMPT('Group profile')
Dynamic Change of Group Profile
Figure 2 CL Program GRP004CL
/*==================================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/GRP004CL) SRCFILE(XXX/QCLSRC) + */ /* USRPRF(*OWNER) */ /* */ /*==================================================================*/ GRP004CL: + PGM PARM(&NEWGRP) DCL VAR(&NEWGRP) TYPE(*CHAR) LEN(10) DCL VAR(&OLDGRP) TYPE(*CHAR) LEN(10) DCL VAR(&USER) TYPE(*CHAR) LEN(10) DCL VAR(&HANDLE) TYPE(*CHAR) LEN(12) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&PASSWORD) TYPE(*CHAR) LEN(10) VALUE(*NOPWD) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(50) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&RTNTYPE) TYPE(*CHAR) LEN(2) DCL VAR(&ERROR) TYPE(*LGL) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) RTVUSRPRF RTNUSRPRF(&USER) GRPPRF(&OLDGRP) CHGUSRPRF USRPRF(&USER) GRPPRF(&NEWGRP) GRTOBJAUT OBJ(QSYS/&OLDGRP) OBJTYPE(*USRPRF) USER(&USER) + AUT(*OBJOPR *OBJMGT *READ *DLT *ADD) CALL PGM(QSYGETPH) PARM(&USER &PASSWORD &HANDLE) CALL PGM(QWTSETP) PARM(&HANDLE) CHGUSRPRF USRPRF(&USER) GRPPRF(&OLDGRP) GRTOBJAUT OBJ(QSYS/&NEWGRP) OBJTYPE(*USRPRF) USER(&USER) + AUT(*OBJOPR *OBJMGT *READ *DLT *ADD) GOTO CMDLBL(ENDPGM) ERROR: + IF COND(&ERROR) THEN(GOTO CMDLBL(ENDPGM)) CHGVAR VAR(&ERROR) VALUE('1') RECEIVE: + RCVMSG MSGTYPE(*ANY) MSGID(&MSGID) RTNTYPE(&RTNTYPE) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) IF COND(&RTNTYPE *NE '15') THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*DIAG) GOTO CMDLBL(RECEIVE) ENDDO SNDPGMMSG MSGID(&MSGID) MSGF(&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM: + ENDPGM
LATEST COMMENTS
MC Press Online