Skip to main content

Get group membership for a user

Log in to add to favourites

Gets the groups the user is a member of by passing the user id or a UserGroupsOptions object as an argument.

getUserGroupsuserIdOrOptions: string | UserGroupsOptions): Promise<PagedList<Group>>

Example for direct parent groups

JavaScript
let userId = "4b262379-5bbe-421e-a429-f6e2ab5a849b";

client.security.users.getUserGroups(userId)
    .then(result => {
        console.log('API call result: ', result);
    })
    .catch(error => {
        console.log('API call error: ', error);        
    });

Example for inherited parent groups

JavaScript
let options = {
    userId: "4b262379-5bbe-421e-a429-f6e2ab5a849b",
    includeInherited: true
};

client.security.users.getUserGroups(options)
    .then(result => {
        console.log('API call result: ', result);
    })
    .catch(error => {
        console.log('API call error: ', error);        
    });

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request