Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all user properties from Microsoft graph

We have an application which has used a local AD to fetch user info. Some customers want to move to the cloud and are using Azure AD. We extended the app to sign users in via owin and now we're fetching users via Microsoft Graph.

However from Microsoft Graph we do not get full user profiles. We want to fetch all properties on users, not just the basic ones.

var client = new RestClient(string.Format("https://graph.microsoft.com/v1.0/users/{0}", userEmail));
request = new RestRequest();
request.Method = Method.GET;
request.AddHeader("Authorization", _token.Token);
var reponse = client.Execute(request);

This only gives me some information though, for example I don't get 'Department' from this. Is it possible to configure in azure what should be returned here, if so then where? Or do I need something other than /users/?

Different customers might have different special properties that need to be fetched. So the best solution would be to have an endpoint to call and get everything, including special properties not standard in azure ad. After that I can parse it on my side. Is this possible?

The app has permission to read both basic and full profiles. Do I need something more?

like image 654
user2235494 Avatar asked Jan 12 '18 16:01

user2235494


People also ask

How do I find my user ID for graph API?

You can get the user information for the signed-in user by replacing /users/{id | userPrincipalName} with /me .

Is Microsoft Graph deprecated?

Microsoft Graph is also more secure and resilient than Azure AD Graph. For this reason, Azure AD Graph has been on a deprecation path since June 30, 2020, and will be retired in the near future as we move all investments to Microsoft Graph.

Is it possible to get full user profile from Microsoft Graph?

We extended the app to sign users in via owin and now we're fetching users via Microsoft Graph. However from Microsoft Graph we do not get full user profiles. We want to fetch all properties on users, not just the basic ones.

How do I retrieve the default properties of a user?

When we retrieve a user from Office 365 it returns the default properties such as - user id, business phone, display name, job title, mail, userprincipalname, mobilephone, and office location. Use Microsoft Graph Explorer to retrieve the default properties of the below request. Request.

How to get the current user information from the user profile?

Create a state interface to hold the data of user profile object Create a function named “ GetMyProfile () ” to fetch the current user information In “ ComponetDidMount () ” pass the created function it will retrieve the user information when page renders Create a child component "UserDetail.tsx" to display user information details.

How to get custom fields from a select field in graph?

You have to specify all fields in the select, as $select=* will only output the key fields in Graph API implementation. So you will not be able to get what you ask (variable custom fields).


1 Answers

That's the normal behaviour of Graph API, see documentation here and this extract:

By default, only a limited set of properties are returned ( businessPhones, displayName, givenName, id, jobTitle, mail, mobilePhone, officeLocation, preferredLanguage, surname, userPrincipalName).

To return an alternative property set, you must specify the desired set of user properties using the OData $select query parameter. For example, to return displayName, givenName, and postalCode, you would use the add the following to your query $select=displayName,givenName,postalCode

You have to specify all fields in the select, as $select=* will only output the key fields in Graph API implementation.

So you will not be able to get what you ask (variable custom fields).

More info on the fields of User can be found here

like image 145
Nicolas R Avatar answered Oct 01 '22 12:10

Nicolas R