1

Here's the scenario:

All users belong to an AD Group. We add that AD group to a SharePoint group. I need to determine if the user is in that SharePoint group using JavaScript. If this is not possible can you direct me to how this can be accomplished via server side code? I would need to have this on a masterpage and available for use throughout the farm.

0

Your JavaScript can use AJAX to call the SharePoint REST API.

To find your groups:

/sites/testing/demoworkflow/_api/web/sitegroups?$filter=LoginName eq 'Testing Members'

To get all users in a group:

/sites/testing/_api/web/sitegroups(49)/users

These REST queries can be built in all kinds of ways. Here's one that finds by group name and part of the user name:

/sites/testing/_api/web/sitegroups/getbyname('Testing Members')/users?$filter=substringof('sam',Email)

You can filter for a single user with several criteria (name, email,etc.):

/sites/testing/_api/web/sitegroups(49)/users?$filter=Email eq 'samc@somedomain.onmicrosoft.com'
  • 1
    This will only get AD User added directly to the SP group. I need to get the users that are in the AD group in the SP Group. – Arale May 18 '18 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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