Help Center> Identity and Access Management> API Reference> API> IAM User Management> Querying the User Groups to Which an IAM User Belongs
Updated on 2023-09-14 GMT+08:00

Querying the User Groups to Which an IAM User Belongs

Function

This API can be used by the administrator to query the groups of a specified IAM user or used by an IAM user to query their own groups.

The API can be called using both the global endpoint and region-specific endpoints.

URI

GET /v3/users/{user_id}/groups

Table 1 URI parameters

Parameter

Mandatory

Type

Description

user_id

Yes

String

IAM user ID. For details about how to obtain a user ID, see Obtaining Account, IAM User, Group, Project, Region, and Agency Information.

Request Parameters

Table 2 Parameters in the request header

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Fill application/json;charset=utf8 in this field.

X-Auth-Token

Yes

String

If the administrator is requesting to query the groups to which an IAM user belongs, see Actions.

If an IAM user is requesting to query their own groups, the user token (no special permission requirements) of the user is required.

Response Parameters

Table 3 Parameters in the response body

Parameter

Type

Description

groups

Array of objects

User group information.

links

Object

Resource link information.

Table 4 groups

Parameter

Type

Description

description

String

User group description.

id

String

User group ID.

domain_id

String

ID of the account to which the user group belongs.

name

String

User group name.

links

Object

User group resource link.

create_time

Long

Time when the user group was created.

Example Request

Request for querying the user groups to which an IAM user belongs

GET https://iam.myhuaweicloud.eu/v3/users/{user_id}/groups

Example Response

Status code: 200

The request is successful.

{
    "groups": [
        {
            "domain_id": "d78cbac186b744899480f25bd0...",
            "create_time": 1578107542861,
            "name": "IAMGroup",
            "description": "",
            "links": {
                "next": null,
                "previous": null,
                "self": "https://iam.myhuaweicloud.eu/v3/groups/07609e7eb200250a3f7dc003cb..."
            },
            "id": "07609e7eb200250a3f7dc003cb7..."
        }
    ],
    "links": {
        "next": null,
        "previous": null,
        "self": "https://iam.myhuaweicloud.eu/v3/users/076837351e80251c1f0fc003afe43.../groups"
    }
}

Status Codes

Status Code

Description

200

The request is successful.

400

Invalid parameters.

401

Authentication failed.

403

Access denied.

404

The requested resource cannot be found.

405

The method specified in the request is not allowed for the requested resource.

413

A resource conflict occurs.

500

Internal server error.

503

Service unavailable.

Error Codes

None