getgroupsbyname (BPX1GUG, BPX4GUG) — Get a list of supplementary group IDs by user name

Function

The getgroupsbyname service gets the number of supplementary group IDs (GIDs) and, optionally, gets a list of those supplementary group IDs for a specified user name.

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1GUG): 31-bit
AMODE (BPX4GUG): 64-bit
ASC mode: Primary mode
Interrupt status: Enabled for interrupts
Locks: Unlocked
Control parameters: All parameters must be addressable by the caller and in the primary address space.

Format

The syntax format is as follows:

AMODE 64 callers use BPX4GUG with the same parameters. The Group_ID_list_pointer_address parameter is a doubleword.

Parameters

User_name_length
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the length of User_name.

User_name
Supplied parameter
Type:
Character string
Character set:
No restriction
Length:
Specified by the User_name_length parameter

The name of a field of length User_name_length that contains the name of the user that you want information about. The name is specified in the Resource Access Control Facility (RACF®) command that defined the user to the system.

Group_ID_list_size
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that specifies the number of fullword entries in the group ID list. This number must be at least as great as the total number of group IDs for the process, or must be 0.

If you specify 0, the program receives only a count of the actual number of group IDs for the calling process, and not a list of those IDs.

Group_ID_list_pointer_address
Supplied parameter
Type:
Address
Length:
Fullword (doubleword)

The name of a fullword (doubleword) that contains a pointer to a storage area where the getgroupsbyname service is to place the list of supplementary group IDs. If Group_ID_list_size is specified as 0, Group_ID_list_pointer_address is ignored, and does not have to be set to a valid address. When the request is successful, the storage is an array of fullwords, each containing a supplementary group ID for the calling process.

Number_of_group_IDs
Returned parameter
Type:
Integer
Length:
Fullword
The name of a fullword in which the getgroupsbyname service returns the number of supplementary group IDs. A -1 is returned if an error is detected.
  • If Group_ID_list_size is specified as 0, the number is the total number of supplementary group IDs for the process.
  • If Group_ID_list_size is specified as greater than 0 and the request is successful, the number is the actual number of group IDs that are put into the area specified by Group_ID_list_pointer_address.
Return_code
Returned parameter
Type:
Integer
Length:
Fullword
The name of a fullword in which the getgroupsbyname service stores the return code. The getgroupsbyname service returns Return_code only if Number_of_group_IDs is -1. For a complete list of possible return code values, see z/OS UNIX System Services Messages and Codes. The getgroupsbyname service can return one of the following values in the Return_code parameter:
Return_code Explanation
EINVAL The Group_ID_list_size parameter was greater than 0 but less than the number of supplementary group IDs; or the User_name or User_name_length fields were incorrect.
EMVSSAF2ERR A system authorization facility (SAF) service had an error.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the getgroupsbyname service stores the reason code. The getgroupsbyname service returns Reason_code only if Number_of group_IDs is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.

In the case of EMVSSAF2ERR, the reason code contains the Resource Access Control Facility (RACF) return and reason codes, respectively, in the two low-order bytes.

For a more detailed description of the RACF GETGNAME service return and reason code values, see the following table:
RACF return code RACF reason code Explanation
8 4 Group count is less than the number of supplemental groups
8 8 Incorrect group list address
8 12 Internal error during RACF processing
8 16 Unable to establish recovery
8 20 Internal error verifying user ID. The user ID might have been revoked.
8 24 User ID is not defined to RACF

Characteristics and restrictions

There are no restrictions on the use of the getgroupsbyname service.

Examples

For an example using this callable service, see BPX1GUG (getgroupsbyname) example.