How to identify if the non-email username is already taken in Azure B2C via MS graph API?

Zahmi Zuhair 141 Reputation points
2023-03-30T03:44:45.39+00:00

Hello support!

How do I check whether a non-email username is taken in B2C via MS graph API using HTTP request?

I want to know how this can be done using api-version=1.0 . Although there are numerous links in the internet, I could not find a solution to address my question.

There's a API to get the user list (/users) and it returns the username. But it does not return the correct username, instead return something like 2345-987654x2324cccccc@xxx.onmicorosoft.com .

What I want to validate is, if a user enters the username for account creation purpose, I wanna validate that username is already exists or not via MS graph API.

Sample username: 'john_smith'.

Appreciate any help to address this issue.

Many Thanks!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,870 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,887 questions
0 comments No comments
{count} votes

Accepted answer
  1. Shweta Mathur 28,196 Reputation points Microsoft Employee
    2023-03-30T07:58:03.72+00:00

    Hi @Zahmi Zuhair ,

    Thanks for reaching out.

    I understand you are trying to get the username registered in B2C using Graph API endpoint but user principal name getting to show random guid rather than actual username.

    This is due to username is part of identities property of the user representing an identity used to sign in to a user account i.e email, username, federated or user principal name.

    User's image

    As you can see in portal as well, username is part of Identities and username is showing under Issuer Assigned Id.

    Getting a user only retrieving the default set of properties only. To get the properties and relationships of user object, you need to use $select which will retrieve issuerAssignedId which represents username.

    User's image

    Reference : https://learn.microsoft.com/en-us/graph/api/resources/objectidentity?view=graph-rest-1.0

    Hope this will help.

    Thanks,

    Shweta

    Please remember to "Accept Answer" if answer helped you.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful