I have a C# script, that creates a user with the following parameters: AccountEnabled, DisplayName, MailNickname, Mail, UserPrincipalName, and PasswordProfile.
When I create a new user, instead of logging in with the mail, the one that works is the UPN. My flow is set to require email for the login, as per the screenshot below.
The user is created, but logging in with the email and password doesn't work, instead it is UPN and password that works. Why is that?
I tried to reproduce the same in my environment and got the results as below:
I created an Azure AD B2C user via Microsoft Graph API by using below query:
POST https://graph.microsoft.com/v1.0/users
{
"displayName": "testb2c",
"identities": [
{
"signInType": "emailAddress",
"issuer": "tenantb2c.onmicrosoft.com",
"issuerAssignedId": "[email protected]"
}
],
"passwordProfile": {
"password": "****",
"forceChangePasswordNextSignIn": false
},
"passwordPolicies": "DisablePasswordExpiration"
}
Now, I created an Azure AD B2C sign-in user flow like below:
When I executed the user flow, I used email address to sign-in like below:
The user got successfully signed-in with email address:
To resolve the issue, make sure to create the user by adding the email to the identities collection. By doing this the user will be able to sign-in with the email address.
Reference: