Tuesday, February 7, 2012

Check whether the current user exists in any SharePoint security groups

public static Boolean isUserInGroup(string groupName)
{
using (SPWeb spwebCurrentWeb = Functions.GetCurrentWeb())
{
SPGroup spGroup = spwebCurrentWeb.Groups[groupName];
if (spGroup!= null)
return spwebCurrentWeb.IsCurrentUserMemberOfGroup(spGroup.ID);
else
return false;
}
}

No comments:

Post a Comment