I am working on a Provider Hosted App (MVC5.0), but I want to make use of SharePoint Groups. Is this possible to achieve, and how to determine whether a user is in a specific group?

  • You will need to write CSOM code to check if user exists in a group. Mar 3, 2015 at 10:27
  • Do you have an example? Mar 3, 2015 at 10:33

1 Answer 1


Here is an example to check if a user exists in a particular group or not using CSOM.

ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection");
GroupCollection collGroup = clientContext.Web.SiteGroups;
Group oGroup = collGroup.GetById(7);
UserCollection collUser = oGroup.Users;

    users => users.Include(
        user => user.Title,
        user => user.LoginName,
        user => user.Email));


foreach (User oUser in collUser)
    if (oUser.LoginName == "YourUserName")
        //User Exits

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.