Custom roles are not returned when i query a users memberof endpoint in graph api

Harishankar B 20 Reputation points
2024-05-13T05:55:00.7266667+00:00

Hi, I have used graph api users memberOf endpoint to get the roles assigned for a user . The response from the endpoint returns all the groups and roles that is assigned for that user , but the custom defined role is not returned . Is there any other way to get the roles assigned for a user.

Thanks.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,821 questions
Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
685 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,825 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yakun Huang-MSFT 785 Reputation points Microsoft Vendor
    2024-05-13T09:01:39.62+00:00

    Hi @Harishankar B

    After my tests, which work well, I created a role named Test Role and granted it to a user, as shown in the image below.

    1

    In Graph Explorer, you can obtain all the roles granted by the following request, including custom roles.

    https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments?$filter=principalId+eq+'<object-id-of-principal>'
    

    2

    As shown in the image, the first one is a custom role for me.

    For more information about this Api:

    https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/custom-assign-graph

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful