0

We have to fetch users who are site collection administrators of all the sites. For some site collections the users are displayed as o365 groups itself. How do we get users within the o365 group using CSOM?

1

This was accomplished by creating an Azure AD app using Microsoft Graph API. Relevant article for those interested is given below:-

Fetch o365 group owners

0

Use below code to get List of users in specific SharePoint group:

ClientContext clientContext = new ClientContext("https://yoursite/");  
GroupCollection collGroup = clientContext.Web.SiteGroups;  
Group getGroup = collGroup.GetById(5);  ///Here you should enter your group ID
UserCollection collUser = getGroup.Users;  
clientContext.Load(collUser);  
clientContext.ExecuteQuery();  
foreach (User getUSer in collUser)  
{  
      Console.WriteLine("User: {0} Email: {2} Login Name: {3}",   
      getGroup.Title, getGroup.Email, getGroup.LoginName);  
}  
  • SharePoint group is not the same as o365-group in this context. The O365-group is an Azure AD group – Robert Lindgren Mar 12 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.