Get user/roles from azure ad

Anurup Majumder 1 Reputation point
2022-06-26T18:21:38.863+00:00

Hi I have a question I have a Azure AD app and inside enterprise app I have some users assigned to some roles.
Can someone tell me a way to get a list of thi users with roles using graph API or java SDK?

215049-image.png

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,172 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Manu Philip 18,681 Reputation points MVP
    2022-06-26T19:36:08.373+00:00

    The easy way to download all role assignment in a directory is already available

    Sign in to the Azure portal or Azure AD admin center. Select Azure Active Directory > Roles and administrators, select All roles, Select Download assignments.
    A CSV file that lists assignments at all scopes for all roles is downloaded.

    215050-image.png

    ----------

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.
    0 comments No comments

  2. ShivaniRai-MSFT-7217 2,741 Reputation points
    2022-06-27T12:46:09.797+00:00

    Hi @Anurup Majumder ,

    You can use this Graph API to get roles assigned to a particular user GET https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments?$filter=principalId+eq+'<object-id-of-principal>' (refer below example screenshot from Graph Explorer):
    215394-image.png

    Here roleDefinitionId is the ID of the role assigned which you can check using this Graph API GET https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions

    Also, if you want to check list of users assigned same role you can use this API GET /roleManagement/directory/roleAssignments?$filter=roleDefinitionId eq '{roleDefinition id}'

    Reference Documents:
    https://learn.microsoft.com/en-us/azure/active-directory/roles/custom-assign-graph
    https://learn.microsoft.com/en-us/graph/api/rbacapplication-list-roledefinitions?view=graph-rest-1.0&tabs=http
    https://learn.microsoft.com/en-us/graph/api/rbacapplication-list-roleassignments?view=graph-rest-1.0&tabs=http

    Hope this helps.
    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.