Tuesday, March 11, 2014

Find out current user exists in an AD group or not

Hi, I have a requirement to find out whether the userrent user is belongs to a specific AD group or not. I struggle a lot to find out the solution. Finally I achieved with the below solution.
Step1 : Add the AD group in a sharepoint group
Step 2: Go to the Site Permission ->Groups
Step 3: AD group name will be appear in the "_layouts/15/groups.aspx" page.
Step 4: Note down the AD group name ID
Step 5:Below code required to check the ID
SPContext.Current.Web.IsCurrentUserMemberOfGroup(ID if AD group name noted on step 4)
:)

No comments: