Check if a user is part of a specific group using Azure B2C claims

728 views Asked by At

One of my project where we are displaying the group claims from Azure AD is failing because the user is part of a huge number of groups. Is there a way to check if the logged in user is part of a specific group and dispaly / filter the group claim to show only specific groups?

1

There are 1 answers

0
Allen Wu On

If you are using Microsoft Graph API to get the group claim, you can filter with the group id like this:

https://graph.microsoft.com/v1.0/users/{user id}/memberOf?$filter=id eq '{group id}'

Obviously this requires you to know the group id in advance. Group name is not supported to filter.

You can also get all the groups by https://graph.microsoft.com/v1.0/users/{user id}/memberOf and filter the group name in your own code. Then return the filter result to the group claim.