I have a SharePoint Add-on for Office 365. It is currently a SharePoint Hosted app and I would like to keep it that way.

My Problem is I am trying to find out if a user is a member of a group either directly or through an AD group. I'm currently querying the user, using the API, for a list of groups they are a member of but this only returns groups that the have been added directly to.

I have seen the workaround on Check users group membership via REST API using AD-Groups in SP-Groups but I don't have control over the SharePoint groups

Do anyone know if it is possible to check if a user is a member of a SharePoint group when they are added via an AD group using the REST API or JSOM?


1 Answer 1


Try this to check the current user group

    <script src="https://c4968397007.dc07.loc:2000/sites/DeveloperSite/Style%20Library/jquery-1.9.0.min.js"></script>

 <script type="text/javascript">

 function TempMethod()




 function CheckCurrentUserMembership() {

 var clientContext = SP.ClientContext.get_current();

 this.currentUser = clientContext.get_web().get_currentUser();


 this.userGroups = this.currentUser.get_groups();




 function OnQuerySucceeded() {

 var isMember = false;

 var groupsEnumerator = this.userGroups.getEnumerator();

 while (groupsEnumerator.moveNext()) {

 var group= groupsEnumerator.get_current();

 if(group.get_title() == "Administrator Group") {

 isMember = true;







 function OnQueryFailed() {



 $(document).ready(function ($) {

 ExecuteOrDelayUntilScriptLoaded(TempMethod, "SP.js");

 SP.SOD.executeFunc('sp.js', 'SP.ClientContext', TempMethod);

 //ExecuteOrDelayUntilScriptLoaded(TempMethod, "SP.ClientContext");




I Hope it will help you, Change it to as per you requirement.

  • Thanks for this, unfortunately, this return the same as the REST API and only get the groups the user is a direct member of. May 30, 2017 at 9:59

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.