Microsoft Graph Group Members Details

Mustafa Gaziani 5 Reputation points
2024-02-15T15:33:01.7166667+00:00

Hello, I am using Microsoft Graph Permission API to fetch DriveItem Permission. this._GraphClient.Drives[aRequest.DriveId].Items[aRequest.DriveItemId].Permissions.GetAsync(cancellationToken: aRequest.CancelToken); Fortunately for the External Users, we are getting the required email addresses for the users in the AdditionalData field. However for Organization Users, the AdditionalData field is empty, and we are not getting the required email address. Is there any way to obtain the email address of Organization Users? Are we missing any permissions? We have already added Sites.ReadWrite.All and Sites.FullControl.All. Additionally, we are not obtaining Group IDs for the "Default Groups" in the Permission API response to fetch Group members' details (Group Member's email addresses). If the DriveItem/Folder is shared afterward, we are getting that GroupID. Is there any way to get the Group ID for all the groups associated (Default Groups and new groups we add afterward) with a DriveItem API / Permission API? await this._GraphClient.Groups[{GROUP-ID}].Members.GetAsync(); await this._GraphClient.Groups[GROUP-ID].Members.GraphUser.GetAsync();

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,310 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Carolyne-3676 211 Reputation points
    2024-02-26T07:32:20.0033333+00:00

    To retrive the email addresses of organization users, you may need to use the User.Read.All or User.ReadWrite.All permissions. The User endpoint should allow you to read the profile and discover any relationships such as group membership.
    Regarding getting the group ID for all groups associated with a DriveItem, the Microsoft Graph API doesn't support this . As a workaround, you can list all groups in your organization and then check their drive for the DriveItem.

    //list all groups
    var groups = await _GraphClient.Groups.Request().GetAsync();
    
    foreach(var group in groups)
    {
        Console.WriteLine(group.Id);
    }
    
    
    
    //And then for each group, check if the DriveItem exists:
    
    var driveItem = await _GraphClient.Groups[group.Id].Drive.Items[driveItemId].Request().GetAsync();
    
    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.