Wednesday 30 July 2014

Programmatically Check Current user in SharePoint Group using C#

Share it Please
 public void CheckcurrentuserinGroup()
        {
            SPGroup grp = SPContext.Current.Web.SiteGroups["GroupName"];
            if (grp != null)
            {
                if (grp.ContainsCurrentUser)
                {
                    //True
                }
                else
                {
                    //false
                    SPUtility.HandleAccessDenied(new Exception("You don’t have access rights to see this content. Contact Administrator"));
                }
            }
        }

No comments:

Post a Comment

Followers

Follow The Author