Hi Yash Tiwari
To check how many security groups a specific user is assigned to in Azure DevOps, you can do this both through the Azure DevOps UI and using the REST API.
Checking Security Groups through the UI:
Go to Azure DevOps -> Select your Project -> Project Settings -> Permissions -> Users -> Click on your username -> Member of -> you can see which security groups belong to.
Checking Security Groups using the REST API:
- First, you need to get the user's ID. You can use the following endpoint to get the user details:
GET https://dev.azure.com/{organization}/_apis/userentitlements?api-version=6.0 - Once you have the user ID, you can retrieve the security groups the user is a member of using the following endpoint:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{userId}?api-version=6.0
Alternatively, you can use the Graph API to list group memberships:
- Get the User Descriptor:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=7.1-preview.1 - List Groups for the User:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{userDescriptor}?direction=up&api-version=7.1-preview.1
In Azure DevOps, an explicit “Deny” always overrides “Allow”, even if the user is in multiple groups.
Additional References:
Hope this helps!
Please Let me know if you have any queries.