Could anyone suggest some way to retrieve user info from AzureAD using JSOM or REST API only..
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
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
);
})