Check if user is member of SharePoint group C#

In this post, I will explain How to check if the current user is a member of SharePoint group using C#.

You might also like to read Get all Groups a user is a member of Using PowerShell

Check if user is member of SharePoint group C#

To Check if the current user belongs to a SharePoint group or not using C#, you should do the following:

  • Create a new SharePoint Solution using Visual Studio.
  • Add a new Visual Web Part.
  • In load function add the following code
if (!SPContext.Current.Web.SiteGroups["groupname"].ContainsCurrentUser)
{
//  do your code
}

Applies To

  • SharePoint 2013.
  • SharePoint 2010.

See Also

Have a Question?

If you have any related questions, please don’t hesitate to ask it at deBUG.to Community.

Leave a Reply

Scroll to Top