Retrieve all the groups from the site using client object model


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Client;
namespace
ClientObjectModel
{
class Program
{
static void Main(string[] args)
{
// Retrieve all the groups from the site using client object model
string siteUrl = "http://serverName:1111/sites/SPSiteDataQuery/";
ClientContext context = new ClientContext(siteUrl);
GroupCollection groupColl = context.Web.SiteGroups;
context.Load(groupColl);
context.ExecuteQuery();
foreach (Group group in groupColl)
{
Console.WriteLine(group.Title + " " + group.Id);
}
Console.ReadLine();
}
}
}
Ebook Download
View all
Learn
View all