SaaS CMS has officially launched! Learn more now.

Update or Change Username



We have arequirement where we want to be able to allow users to change their UserName. As episerver it does not allow username to be changed. 

  • The username property of Membership object is readonly. So I am not able to change that.
  • Also the Edit screen in episerver admin side for CustomerContact->User Account->Edit, "UserName" is readonly.

Does this mean we can never change UserName? We do need to change it though. Would really appreciate any input. Thanks!

Feb 16, 2015 20:30

You cannot change a username once it has been created, that is a restriction within ASP.NET. But you can create a new user in ASP.NET and link it to the Customer in Commerce.

Something like:

// Create new user

var target= Membership.CreateUser(newUserName, newPassword, userEmailAddress);

if (RoleExists(AppRoles.EveryoneRole) &&!SecurityContext.Current.CheckUserInGlobalRole(target, AppRoles.EveryoneRole))

SecurityContext.Current.AssignUserToGlobalRole(target, AppRoles.EveryoneRole);

// Add user to registered role

if (RoleExists(AppRoles.RegisteredRole) && !SecurityContext.Current.CheckUserInGlobalRole(target, AppRoles.RegisteredRole))

SecurityContext.Current.AssignUserToGlobalRole(target, AppRoles.RegisteredRole);

// Get Customer

var customerContact = CustomerContext.Current.GetContactForUser(currentUser);

//assign new user to customer

customerContact.UserId = ToTypedString(target.ProviderUserKey);

//  save customer


// delete 'old' account


Edited, Feb 17, 2015 9:39


Seems like it was discussed earlier here :

Feb 17, 2015 12:35

Hi sapna,

I haven't worked with Commerce before, I tested this with EPiServer CMS 7.5 only.

I guess you only want to change the username, and keep the old email.

Usernames are stored in the Users table. UserName is not PK / FK / unique constraint, so you can safely change it there.

User access rights are stored in tblContentAccess table. You need to change the Name column (free text).

Just make sure that 'new username' is not already in use.

Feb 17, 2015 13:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.