I have a Sharepoint group, and within this group, is an Active Directory group. I want to know if I can send a query to find if the current user is a member of the AD group, from Javascript. I do not want to go down the path of needing to copy the members of the AD group to a SP group, so I want to know if I can simply query against the AD group from Javascript.

  • You would need to query from JS -> Active Directory. SharePoint has no knowledge of who is in that group until a specific user is enumerated against the group (e.g. they attempt to access the SharePoint resource).
    – user6024
    Feb 22, 2016 at 18:47
  • Have you any information on how to query Active Directory from Javascript? Looking around I have failed to find information on how to do that.
    – cm2
    Feb 22, 2016 at 18:48
  • Per stackoverflow.com/questions/3319249/…, JavaScript won't be able to.
    – user6024
    Feb 22, 2016 at 19:19
  • This is unfortunate news, I suppose from here the next step would be to set up some codebehind on my aspx page to access AD
    – cm2
    Feb 22, 2016 at 19:25
  • 1
    Yep, some SSOM code would do the trick. There you can use the System.DirectoryServices namespace.
    – user6024
    Feb 22, 2016 at 19:27

3 Answers 3


You can query AD membership using this workaround:

var clientContext = new SP.ClientContext();
var groupId = 5; // the group membership ID for the group you want to check
var group = clientContext.get_web().get_siteGroups().getById(groupId);
        var isMemberOfGroup = group.get_canCurrentUserViewMembership() && group.get_onlyAllowMembersViewMembership();
    function(sender,args){"Whoops! "+alert(args.get_message());}

Solution thanks to https://stackoverflow.com/questions/33164019/user-is-part-of-an-ad-group-that-is-nested-in-the-sharepoint-group-how-to-relate


Unfortunately AD cannot be queried in any way via Javascript, so the alternative I will pursue is using codeBehind to accomplish it.


If you want to do it via javascript, create a page or some other securable object, secure it with the desired SharePoint group, then try to ajax it. It should then force a check if the user has access (by way of the AD group in your SP group).

Based on the response code, do what ever you need to do.

  • What exactly would I be ajaxing here? Just trying to get the object or page at all? Then if it succeeds that means that the current user exists in the AD group?
    – cm2
    Feb 24, 2016 at 17:50
  • Correct, you could create a single page (it doesn't need content, just to be a major version and be approved) or a text file secured as desired and try to AJAX it. If it returns a 404, they don't have access. Feb 24, 2016 at 18:00
  • This is a very interesting idea, I did not know that Sharepoint would force the check. I'll definitely give this a shot!
    – cm2
    Feb 24, 2016 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.