Sitecore Extranet Authentication with Email Address

Sitecore Extranet Authentication with Email Address

Description

If you try to create a new user on Sitecore you will notice that there are a few required fields you need to fill in.

One of these fields is the ‘user name’ that is going to be used for authentication.

If you try to type in an email on this field Sitecore is going to return a message such as:
“User name is not valid in the selected domain”
That is because Sitecore user manager dialog box is originally configured to validate user name rather than email. This validation is based on a regular expression.

 

Solution

To modify this behavior, add the following line to your web.config file:

<setting name="AccountNameValidation" value="^\w[\w\s\.\@]*$" />

Hint: Depending on the Sitecore version the ‘settings’ tag could be on a file called SitecoreSettings.config located under App_Config/Include.

Please note that by allowing users to use email address as user name, you must change the membership provider in Sitecore to require a unique email to each user.
If you don’t do this some users might share email addresses and your project is going to have a bug.
On your web.config find the following line and update the ‘requiresUniqueEmail’ attribute value to TRUE.
<add name="sql" 
type="System.Web.Security.SqlMembershipProvider" connectionStringName="core"
applicationName="sitecore" 
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" requiresQuestionAndAnswer="false" 
requiresUniqueEmail="true" 
maxInvalidPasswordAttempts="256"/>

 

For more information about regular expressions please click here.

Thank you

Leave a Comment

%d bloggers like this: