I asked this queston on Stackoverflow and also here and I have not yet received an answer. I hope this is the right place to ask:
This question was also posted on StackOverflow.
I actually have two questions which may possibly be related:
Question 1: Why does user personal email address appear in Azure portal as User Principal Name?
Question 2: How do I look up a user by their personal email address?
The email address I will be looking for is the one used as a sign in name so I expect that it should appear in a property like signInNames as is mentioned below.
Steps to reproduce:
Log into Azure portal, Look at a random user and observe their User Principal Name.
Note it appears in the format of a personal email address (joe@somedomain.com). Copy the users Object ID.
In code, create a new GraphServiceClient and retrive the user by object ID using the Object ID copied in the step above.
GraphServiceClient client = GetGraphServiceClient();
User user = await client.Users[userID].Request().GetAsync();
In the User object that is returned, note the value of UserPrincipalName is not what is shown in Azure portal as noted in the first step. It is instead an assigned identifier: cpim_96fe-48b5-88a2-9ac960a6bdab@mydomain.onmicrosoft.com.
Attempt to find a user using personal email address See also:
GraphServiceClient client = GetGraphServiceClient();
IGraphServiceUsersCollectionPage users = await client.Users.Request().Filter("userPrincipalName eq 'joe@somedomain.com'").GetAsync(); // Count = 0
IGraphServiceUsersCollectionPage users = await client.Users.Request().Filter("mail eq 'joe@somedomain.com'").GetAsync(); // Count = 0
As recommended by this answer, this does not work either:
IGraphServiceUsersCollectionPage users3 = await client.Users.Request().Filter("signInNames/any(x:x/value eq 'joe@somedomain.com')").GetAsync(); // error Filter not supported.
My Azure Application has User.ReadWrite.All permission. Personal email address does not appear as any property value for any object I retrieve.


