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.

2 Answers 2

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"]);
}
2
  • Yeah it worked for me... thanx mate
    – Kb15
    Commented Sep 23, 2014 at 9:14
  • i am getting this error "You do not have permission to perform this action or access this resource." in browser
    – Madhav
    Commented Jun 21, 2016 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.

4
  • .SiteUsers in not available in SharePoint 2010, it is for SP2013
    – Kb15
    Commented Sep 19, 2014 at 12:49
  • Updated. Try SiteUserInfoList. It may help you.
    – Aanchal
    Commented Sep 19, 2014 at 12:58
  • Can you please guide me further. I tried to get Users with what you updated gave but I failed..
    – Kb15
    Commented Sep 19, 2014 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?
    – samolpp2
    Commented Feb 5, 2016 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.