Retrieve SiteCollection Groups

SharePoint 2010 now supports the client side programming using Client API Classes and namespaces. Using those class references, we can see how to retrieve the list of Site collection groups.

Before start the code, add the two namespaces Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime as references to the project.

The above mentioned two DLL’s are available under " SharePoint Root > ISAPI "

using Microsoft.SharePoint.Client;


ClientContext context = new ClientContext("http://spserver");
Web web = context.Web;         
GroupCollection groups = web.SiteGroups;
foreach (Group grp in groups)
Console.WriteLine("Press any key to continue…");

Declare the ClientContext to get the context information of a site collection and then load the site collection groups to the that. Then execute the ClientContext using context.ExecuteQuery() to retrieve the collection of groups available under particular SharePoint Site Collection.

The result we got for the above mentioned code as follows,


Shantha Kumar
Shantha Kumar
Articles: 269

Leave a Reply

Your email address will not be published. Required fields are marked *