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
- Work with SharePoint Lookup Field Programmatically.
- Bind dropdown from SharePoint List in C#.
- Get and Set a SharePoint URL Field Value Programmatically.
- Get and Set User Field SharePoint C#.
- How to get the Title and URL of SharePoint Page via Object Model?
- Get and Set a SharePoint Multiple Choice Field Value Using Server Object Model C#.
- Retrieve a SharePoint Choice Field Value Using Server Object Model C#.
Have a Question?
If you have any related questions, please don’t hesitate to ask it at deBUG.to Community.