Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to look up a user by personal email address? #755

Closed
sam-wheat opened this issue Aug 7, 2020 · 4 comments
Closed

How to look up a user by personal email address? #755

sam-wheat opened this issue Aug 7, 2020 · 4 comments

Comments

@sam-wheat
Copy link

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.

@ghost ghost added the Needs: Triage label Aug 7, 2020
@ghost ghost added this to Issues to triage in Graph SDK - Triage Aug 7, 2020
@sam-wheat
Copy link
Author

Hi I don't mean to be impatient but I have been checking this request daily because I really need an answer. If I have posted in the wrong place or not provided sufficient info please let me know. Thanks much!

@MIchaelMainer
Copy link
Contributor

This question is much better address on StackOverflow as this isn't an issue with the client library. The first question is not about Microsoft Graph and I don't know the answer for the second question. I suspect that this is an Azure B2C scenario -- what is supported or not is often times a challenge. I don't see any documentation on this scenario.

Graph SDK - Triage automation moved this from Issues to triage to Closed Aug 12, 2020
@sam-wheat
Copy link
Author

I've already posted on a Stackoverflow where the question was ignored, If this is the correct place to ask please reopen the question so a more qualified person can answer.

Thanks

@MIchaelMainer
Copy link
Contributor

StackOvewflow is the correct place to ask these questions. This repo is specifically for the client library and is not for service API support. The service API folks are more likely to find the questions on StackOverflow.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

2 participants