0 pts.
 CL test for user in group
CLP
I need to test for a specific user in a group to allow them access to a menu option in a CL program. I have already created the new group and added users to it. I need help with the actual CL command to test &user in &group. Tks

Software/Hardware used:
ASKED: September 22, 2006  12:12 PM
UPDATED: September 25, 2006  9:25 AM
  Help
 Approved Answer - Chosen by TomLiotta

You need to retrieve and test the group and supplemental groups for the user and check these to see if they contain the group you are interested in. The following CL programs returns a '1' if the group is found and a '0' if not:

PGM PARM(&p1USER &p1GRP &p1RTNC)

DCL VAR(&P1USER) TYPE(*CHAR) LEN(10)
DCL VAR(&P1GRP) TYPE(*CHAR) LEN(10)
DCL VAR(&P1RTNC) TYPE(*CHAR) LEN(10)

DCL VAR(&PRFGRP) TYPE(*CHAR) LEN(10)
DCL VAR(&PRFSUP) TYPE(*CHAR) LEN(150)
DCL VAR(&POS) TYPE(*DEC) LEN(3 0) VALUE(0)

/* 1) Retrieve user's group and supplemental group... */

RTVUSRPRF USRPRF(&P1USER) GRPPRF(&PRFGRP) +
SUPGRPPRF(&PRFSUP)

/* 2) If the passed Group matches either the user's group or */
/* is contained in the supplemental group then we can return */
/* a valid condition... */

CHGVAR VAR(&P1RTNC) VALUE('0')

IF COND(&P1GRP *EQ &PRFGRP) THEN(DO)
CHGVAR VAR(&P1RTNC) VALUE('1')
ENDDO

ELSE CMD(DO)
CALL PGM(QCLSCAN) PARM(&PRFSUP 150 1 &P1GRP 10 +
0 0 '*' &POS)
IF COND(&POS *GE 1) THEN(CHGVAR VAR(&P1RTNC) +
VALUE('1'))
ENDDO

ENDPGM

Hope it helps

Jonathan

ANSWERED:  Sep 25, 2006  9:25 AM (GMT)  by TomLiotta

 
Other Answers:

DCL VAR(&GRPPRF ) TYPE(*CHAR) LEN(10)
RTVUSRPRF GRPPRF(&GRPPRF)

Last Wiki Answer Submitted:  September 25, 2006  8:26 am  by  BobbyS40   10 pts.
Latest Answer Wiki Contributors:  BobbyS40   10 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _