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/

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
13,500 questions
Microsoft Graph Groups API
Microsoft Graph Groups API
A Microsoft API that creates and manages different types of groups and group functionality.
188 questions
Microsoft Graph Applications API
Microsoft Graph Applications API
A Microsoft API that enables you to manage these resources and actions related to applications in Azure Active Directory.
492 questions
Microsoft Graph Users API
Microsoft Graph Users API
A Microsoft API that allows you to build compelling app experiences based on users, their relationships with other users and groups, and the resources they access for example their mails, calendars, files, administrative roles, group memberships.
636 questions
No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 20,376 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