Hi Jeff,
by using the SPUser.Groups property you can easily enumerate the groups that a
user has been assigned to. You can check whether a particular user is a member of the SharePoint
group or not, taking into account AD group membership with using
the SPGroup.ContainsCurrentUser property as shown below:
private bool CheckGroupMembership(string spGroupName)
{
try
{
// Definition Web and website
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
SPWeb web = site.OpenWeb(SPContext.Current.Web.ID);
SPGroup checkGroup = web.Groups[spGroupName];
if (checkGroup != null)
{
return checkGroup.ContainsCurrentUser;
}
else { return false; }
}
}
catch (Exception ex)
{
return false;
}
}
}
Hope that helps.
Regards,