Reputation: 95
Currently I have a tenant in Azure B2C and a User flow that uses phone number and recovery e-mail to sign up a user in Active Directory. I am using the Microsoft Graph API to fetch the list of users, however, it never returns their phone number that they signed up with. If I view the users in the Active Directory portal, I see the phone number under User Principal Name.
User as it appears in AD with the phone number under User Principal Name
But in the JSON returned from the Microsoft Graph API (https://graph.microsoft.com/v1.0/user) the userPrinicpalName is not the phone number but a random string (probably the OID).
{
"businessPhones": [],
"displayName": "xxxxx",
"givenName": "xxxxx",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Saleem",
"userPrincipalName": "[email protected]",
"id": "f5casd1e-ce6e-4c15-a36d-a710b4ca77c2"
}
Is there any way to get the list of users from my AD along with their phone numbers? I have also tried using a filter as follows to fetch a user by their phone number https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '+9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com') but this returns an empty array. Please help! My ultimate objective is to check if a user exists against a given phone number and return their OID.
Upvotes: 1
Views: 3850
Reputation: 602
I was able to recreate your problem, and found that the plus (+) sign in the Filter was the problem. By encoding it with standard Url Encoding, I found success.
The +
sign gets converted to %2B
https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '+9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com')
to
https://graph.microsoft.com/v1.0/users?$filter=identities/any(c:c/issuerAssignedId eq '%2B9231xxxxxxxx' and c/issuer eq 'guardianlitedev.onmicrosoft.com')
Upvotes: 0