Retrieve all the users from a particular group 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 users from a particular group
string siteUrl = "http://serverName:1111/sites/SPSiteDataQuery/";
ClientContext context = new ClientContext(siteUrl);
GroupCollection groupColl = context.Web.SiteGroups;
Group group = groupColl.GetById(7);
UserCollection userColl = group.Users;
context.Load(userColl);
context.ExecuteQuery();
foreach (User user in userColl)
{
Console.WriteLine(user.LoginName);
}
Console.ReadLine();
}
}
}
Ebook Download
View all
Learn
View all