I have a sharepoint permission group with some permissionslevels. The name is: "SPProgress". Inside this group I have inserted a AD usergroup with the name "ADProgress".

I would like to check in code if the current user is exist in the SharePoint permision group "SPProgress". But if the current user is exist in the AD usergroup "ADProgress", it needs to return true.

I set the currentuser outside the RunWithElevatedPrivileges in a parameter.

SPUser currentUser = SPContext.Current.Web.CurrentUser;
SPGroup someGroup = somegroup...


if(IsUserExistInGroup(currentUser, someGroup ))
// do some logic

Since you are using CurrentUser and if you create the a SPWeb object outside of the runwithelevatedprivileges this code should work for you for the SharePoint group:


Since you are using the current user, this code should work for you for the AD group:

  • I am looking for some solution for inside the runwithelevatedprivileges. – Ola Feb 26 '13 at 18:40
  • Why can't you run this within runwithelevatedprivileges??? Just use the web object created outside runwithelevatedprivileges so it will use the currently logged in user. – Steve Lineberry Feb 26 '13 at 18:53
  • I am looking for some solution with SPUser and SPGroup as parameters. With these 2 parameters inside the RunWithElevatedPrivileges I would like to check the membership. – Ola Feb 26 '13 at 19:20
  • Right, that should be fine. The issue comes with you CREATE the spweb or spsite object inside the runwithelevatedprivileges. When that happens the service account is what is assigned to the usertoken and when you try to check permissions they always return true. – Steve Lineberry Feb 27 '13 at 14:06

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.