Get All Site Groups in SharePoint using CSOM

The example in this topic show how to use CSOM to Get All Site Groups in SharePoint

  • using Microsoft.SharePoint.Client;
  • using System.Linq;
  •  
  • using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
  • {
  • // Get all the groups at site level
  • GroupCollection oGroupCollection = clientcontext.Web.SiteGroups;
  •  
  • clientcontext.Load(oGroupCollection);
  • clientcontext.ExecuteQuery();
  •  
  • // Iterate through each group
  • foreach (Group oGroup in oGroupCollection)
  • {
  • // Print group title
  • Console.WriteLine(oGroup.Title);
  • }
  • }

Thank you for reading this article. This code was tested in SharePoint 2013

We value your feedback:

Page URL:

Name:

 

Email:

 
 

Feedback:

 

© 2019 Code SharePoint