AD Group within SharePoint Group find user is present or not RRS feed

  • Question

  • Hi,

    I have SP group say "SPGroup" within that i have added "ADGroup".

    I want to check if user is already added in "ADGroup". i am able to find user directly from sharepoint group using REST API "http://<site url>/_api/web/sitegroups(<group id>)/users" but it is not working in case of AD group.

    Please suggest.

    Thursday, December 29, 2016 4:03 PM

All replies

  • Hi Saksham,

    We can check if a user is in AD group like below:

    using System.DirectoryServices.AccountManagement;  
    protected bool CurrentUserIsMemberOfGroup(string groupName)  
        string userLogin = SPContext.Current.Web.CurrentUser.LoginName;  
        // To get the right context, run with elevated privileges  
            var principalContext = new PrincipalContext(ContextType.Domain);  
            var userPrincipal = UserPrincipal.FindByIdentity(principalContext, System.DirectoryServices.AccountManagement.IdentityType.SamAccountName, userLogin);  
            var group = GroupPrincipal.FindByIdentity(principalContext , groupName);  
            return userPrincipal.IsMemberOf(group);   

    More information:

    Check if a SharePoint user is member of an AD group


    Best Regards

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Friday, December 30, 2016 6:08 AM
  • Thanks Jerry,

    But i am looking to find users in AD group within sharepoint2013 designer workflow itself. 

    Not sure if it is possible.



    Sunday, January 1, 2017 1:22 PM