Azure B2C username allowed characters conflicting information

377 Views Asked by At

If I use a built in flow that is set to use username sign up I get the following validation message when using characters like # in username:

The username you have provided is not valid. It must begin with an alphabetical character or number, and can only contain alphanumeric characters and the following symbols: _

If I use the Azure Portal and go to B2C tenant->users and create a user, I am able to use many more characters accepted, # is accepted for example:

enter image description here

On the Azure portal again, if I use "," for example I am getting below validation message:

Invalid user name. User name should be a valid local part of an email address.

Which one of these correct and what characters are we allowed to use? We will do a large migration with 8million users from a legacy system and want to make sure we do not run into issues.

1

There are 1 best solutions below

1
On

Invalid user name. User name should be a valid local part of an email address.

The issue you are encountering is because Azure AD B2C only supports alphanumeric characters when using the default User Flow, and you cannot sign up with usernames containing non-alphanumeric values Refer to the same issue on MS Q&A answered by Shweta Mathur.

When I try to create a user with special characters using a user flow, I also receive the same error as you.

enter image description here

Below are the characters allowed when you create a user from the Azure AD B2C Portal. You can also refer the Can't create a username that contains special characters.

  A – Z
  a - z
  0 – 9
 ' . - _ ! # ^ ~

User creation in portal

enter image description here

In order to create a user with required special characters in Azure AD B2C, you can use custom policies.

Refer: Create custom policies in Azure Active Directory B2C for more details about Azure AD B2C Custom Policy.