Changing User Name

Posted by Community Admin on 04-Aug-2018 19:21

Changing User Name

All Replies

Posted by Community Admin on 15-Feb-2012 00:00

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?

Posted by Community Admin on 16-Feb-2012 00:00

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();
            
        


Regards,
Victor Velev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 16-Feb-2012 00:00

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

Posted by Community Admin on 16-Feb-2012 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed