Your strategic advantage starts here

Find a Users SharePoint Group Membership

Find a Users SharePoint Group Membership

This example shows how we can find a users SharePoint group membership by utilising SPGroupCollection.  Remember that if you are running your code with SPSecurity.RunWithElevatedPrivileges, you should set the SPUser value OUTSIDE of this elevated code otherwise it will not work for the current user running the browser session.

SPUser user = SPContext.Current.Web.CurrentUser;

SPGroupCollection groupColl = user.Groups;
foreach (SPGroup grp in groupColl)
{
    groupMembership.Text += grp.Name + ",";
}

 

Related Posts
Leave a Reply
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day