I want to fetch all groups and users (outside of the the sharepoint group) from a Site collection using C# client object model. Currently i am bale to fetch all the groups and users inside those groups. But if i open Site permissions, and if any users are given permission directly (without including in any groups), how do i retrieve these user's? Please suggest.

1 Answer 1


Web.SiteUsers gives all users whether they are added in a group or added explicitly without being part of any group.

using (var clientContext = new ClientContext("http://aissp2013:90"))
    Web web = clientContext.Web;
    UserCollection coll = web.SiteUsers;
    foreach (User user in coll)
        if (user.Groups.Count == 0)
  • I tried with this. But i do get many users which i am not able to see them on site permissions page.
    – user38433
    Mar 4, 2015 at 11:09
  • As mentioned in the answer, it will also show users which are added in groups. Mar 4, 2015 at 11:15
  • Is there a way to get only the users who are added explicitly outside of any sharepoint groups?
    – user38433
    Mar 4, 2015 at 11:17
  • 1
    See my updated answer. Just check the count of the number of groups for a user. If it is 0, that means user has been explicitly added. Mar 4, 2015 at 11:32
  • is this possible using ECMA script or JSOM, for a SP 2010 site collection and sub site
    – samolpp2
    Jul 12, 2018 at 8:32

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.