get user/group role id by appid and user object id

Tibadaya, Nirbhay 21 Reputation points
2023-01-09T19:21:42.993+00:00

I have registered the app with Azure AD and created some of the roles for user and group.

Now, How can I get user/group role id by userid/userprincipal?

Through below endpoint Im getting all roles listed for my application.
https://graph.microsoft.com/v1.0/applications/<appId>/appRoles/

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,051 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,257 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 45,186 Reputation points
    2023-01-10T03:12:01.553+00:00

    Hi @Tibadaya, Nirbhay

    You can use this api to list all users or groups assigned to the enterprise application:

    https://graph.microsoft.com/v1.0/servicePrincipals/{object id of the app}/appRoleAssignedTo
    

    Alternatively, you can retrieve a list of app roles that have been assigned to a specific user or group based on the object ID of the user/group.

    GET /users/{id | userPrincipalName}/appRoleAssignments
    GET /groups/{id}/appRoleAssignments
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

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.