Changing User Name
Is there any way to change a username once a user has been created? The thread here for SF 3.x says no:
http://www.sitefinity.com/devnet/forums/sitefinity-3-x/security/change-username.aspx
Should I presume this is also the case for 4.x?
Hi,
You can use our API to change the username. Here is a code sample for you:
public void ModifyUser(string username, string newUsername)
UserManager userManager = UserManager.GetManager();
UserProfileManager profileManager = UserProfileManager.GetManager();
User user = userManager.GetUsers().Where(u => u.UserName == username).SingleOrDefault();
if (user != null)
user.SetUserName(newUsername);
userManager.SaveChanges();
Dear Victor
The user name can not be changed in the back-end but with a few lines of code.
Just wondering what would happen if you asing the name of an allready existing user?
Markus
Hi Markus,
You most probably will get an error that such username exists, but in order to avoid that you can create some custom logic for checking whether the desired username exists in the database.
Greetings,
Victor Velev
the Telerik team