How to use Toolkit Import with usernames that have special characters

Nate Axtell asked on June 27, 2019 17:51

I am working with Import Toolkit 12, selecting user information from another CMS database for import. Usernames in the other database contain special characters that Import Toolkit doesn't allow by default, i.e. #, $, !, &, etc. It shows this message:

An error occurred on import: The object code name 'abc&def' is not valid. The code name can contain only alphanumeric characters, some special characters (_, -, .) and cannot start or end with '.'.

I have found the app settings CMSEnsureSafeUserNames which appears to change the default value of CMSUserValidationRegEx to use a less restrictive Regex, ^[a-zA-Z0-9_\-.\@!#$%&'*+/=?^_`{|}~]+$. When I include this app setting in both the CMS and the MVC web.config files, it has no affect on the Toolkit Import behavior,

<add key="CMSEnsureSafeUserNames" value="false" />

I also tested with this app setting to see if explicitly setting it would help, but it doesn't.

<add key="CMSUserValidationRegEx" value="^[a-zA-Z0-9_\-.\@!#$%&'*+/=?^_`{|}~]+$" />

Is there anything that I can do to change the behavior of the Import Toolkit in terms of usernames? If not, what are my other alternatives for import here other than manipulating the usernames in the source CMS?

Recent Answers


Brenden Kehren answered on June 27, 2019 22:13

This key <add key="CMSEnsureSafeUserNames" value="false" /> is only valid when importing users from Active Directory. Same is true with this key <add key="CMSUserValidationRegEx" value="([A-Za-z0-9-]+)" />, only valid when importing users from Active Directory.

You could use the API to perform the "import" for you by adding all those users to a table in the Kentico database, then running a console app that gets all those users and creates the user in Kentico. We've had to do this before. We've also kept a list of users whos username changed because of the requirements of Kentico.

0 votesVote for this answer Mark as a Correct answer

Nate Axtell answered on June 27, 2019 22:34

I saw that CMSEnsureSafeUserNames applied to Active Directory, but was hoping that CMSUserValidationRegEx did not. It seems like it doesn't based on the documentation. However, it doesn't list the Import Toolkit.

Applies when new users register on the website, are created in the administration interface or through the API, and when the name of an existing user is modified.

I was also hoping not to have to write a custom import using the API in a Console App, but as you suggest that looks to be my only solution. I'll double check the app setting CMSUserValidationRegEx in the Console App to verify whether it will work with the API or it truly is only for use with Active Directory. I'll report back on what I find.

Thanks for the help!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.