How to allow application to read users and group memberships with limited permissions

Jason Lines 0 Reputation points
2023-07-23T05:39:33.18+00:00

I have a background service that needs to get all of the user profiles and the groups they belong to. I'm assuming that I will call the memberOf endpoint for each userid in order to get their groups. The problem is that this endpoint seems to require Directory.Read.All permissions, and that provides way more access to information than I need.

https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http

Is there a way to get a list of groups that a user belongs to and the group names without enabling the entire Directory.Read.All permission?

Microsoft Security Microsoft Entra Microsoft Entra ID
Microsoft Security Microsoft Graph
{count} votes

3 answers

Sort by: Most helpful
  1. Andy David - MVP 157.4K Reputation points MVP Volunteer Moderator
    2023-07-23T14:49:29.0166667+00:00
    1 person found this answer helpful.

  2. CarlZhao-MSFT 46,371 Reputation points
    2023-07-24T06:40:04.5633333+00:00

    Hi @Jason Lines

    Try granting User.Read.All application permission to your app to list user sets. You only need to expand the /memberOf endpoint when listing user sets to list all groups that all users belong to, you don't need to grant additional permissions for this.

    https://graph.microsoft.com/v1.0/users?$expand=memberOf
    

    Note that the values of directory-level attributes will not be returned.

    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.


  3. Alexandru Burac 0 Reputation points
    2023-11-09T04:41:10.59+00:00

    How about just sending a group claim, which ensures the app will get only the groups list.

    User's image

    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.