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 + ",";
}