I have a custom SharePoint 2016 on prem Navigation with links only certain people can see. Currently I am using a SP Group and manually updating it when there is a new hire with their AD account.

What I would like to do is bypass the SP Group and use AD groups so I don't have to manually update anymore. Hope this makes sense.

Below is my code to read from the SP Group.

   var allowedGroups = ["IT"];
   var isInAllowedGroup = false;

   var userid= _spPageContextInfo.userId;
   var requestUri = _spPageContextInfo.webAbsoluteUrl + '/_api/web/CurrentUser/Groups?$select=Id,Title';

   var requestHeaders = { "accept" : "application/json;odata=verbose" };
     url : requestUri,
     contentType : "application/json;odata=verbose",
     headers : requestHeaders,
     success : onSuccess,
     error : onError

  function onSuccess(data, request){
 var s='';
  for (var i = 0; i < data.d.results.length; i++)
 s +=data.d.results[i].Title+'\n';

  var groupName = data.d.results[i].Title;
   if (allowedGroups.indexOf(groupName) > -1)
    isInAllowedGroup = true;

 $("#IT").css('display', 'block');

   function onError(error) {


thanks you in advance.

1 Answer 1


I would try to modify your process, and not your code. Add the AD group to the SharePoint group, then add users to the AD group.

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.