0

I have gone through this link : http://msdn.microsoft.com/en-us/library/office/ee538244(v=office.14).aspx

But through this I am only able to get user details which are in groups. I am not able to get users other then groups. I need all means all users of the site in client object model.

Please help. Thank You.

9

You can query SiteUserInfoList to get all users in a site.

ClientContext clientContext = new ClientContext("http://your site/");
Web web = clientContext.Web;
List siteUserInfoList = web.SiteUserInfoList;
CamlQuery query = new CamlQuery();
query.ViewXml = "";
IEnumerable<ListItem> itemColl = clientContext.LoadQuery(siteUserInfoList.GetItems(query));
clientContext.ExecuteQuery();
foreach (var item in itemColl)
{
    Console.WriteLine("ID:{0}  Email:{1} Title:{2}", item.Id, item["EMail"], item["Title"]);
}
  • Yeah it worked for me... thanx mate – Kaushal15 Sep 23 '14 at 9:14
  • i am getting this error "You do not have permission to perform this action or access this resource." in browser – Madhav Jun 21 '16 at 13:27
1

You can try following:

    Web web = context.Web;

List siteUserInfoList = web.SiteUserInfoList;  

context.Load(siteUserInfoList);

context.ExecuteQuery();

This way you can get all users.

  • .SiteUsers in not available in SharePoint 2010, it is for SP2013 – Kaushal15 Sep 19 '14 at 12:49
  • Updated. Try SiteUserInfoList. It may help you. – Aanchal Sep 19 '14 at 12:58
  • Can you please guide me further. I tried to get Users with what you updated gave but I failed.. – Kaushal15 Sep 19 '14 at 13:57
  • can i use the above code in my SP 2010 designer's custom new form.aspx page with within a javascript function? – userAZLogicApps Feb 5 '16 at 7:18

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.