0

Could anyone suggest some way to retrieve user info from AzureAD using JSOM or REST API only..

0

You can use the Azure Graph API in the postman tool to get the exact query.

Please read the below steps how to get - steps are originally explained here.

Microsoft introduces Graph APIs for fetching user details and roles attached. User Detail API:

https://graph.windows.net//users?api-version=1.6

Authorization:Access Token

Access token you can generate using resource as https://graph.windows.net/ and authentication endpoint as https://login.microsoftonline.com/.

Note: You must have Microsoft Graph API Permission as well.

Below are some other graph API endpoints:

https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/directoryroles-operations

Directory roles:

https://graph.windows.net/myorganization/directoryRoles?api-version=1.6

List the users with roles:

https://graph.windows.net/myorganization/directoryRoles/ce8c598b-20eb-42b6-89c6-cf6c184ba416/$links/members?api-version=1.6

0

You could create SPFx solution to call Graph api to get user profile.

Official tutorial here

this.props.context.aadHttpClientFactory
    .getClient('https://graph.microsoft.com')
    .then((client: AadHttpClient) => {
      // Search for the users with givenName, surname, or displayName equal to the searchFor value
      return client
        .get(
          `https://graph.microsoft.com/v1.0/users?$select=displayName,mail,userPrincipalName&$filter=(givenName%20eq%20'${escape(this.state.searchFor)}')%20or%20(surname%20eq%20'${escape(this.state.searchFor)}')%20or%20(displayName%20eq%20'${escape(this.state.searchFor)}')`,
          AadHttpClient.configurations.v1
        );
    })
  • Can we use graph API in a JSOM based running solution? – Tezz Chaudhary Apr 23 '20 at 6:17
  • Can't do this yet. – Lee_MSFT Apr 23 '20 at 8:36

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.