When a visitor registers a new account on an ASP.NET website that uses the Membership system, they are prompted (by default) for their username, password, e-mail address,
and other pertinent information. Along with functionality for registering new accounts, the ASP.NET Membership system provides page developers techniques for modifying
information about users. For instance, with just a couple of lines of code you can change an existing user's e-mail address, approve a user, or unlock them (if their account was
locked out). However, there are certain bits of user information that cannot be modified through the Membership API, such as the username.
For most sites this is a non-issue. Once a visitor has registered an account that username is fixed; if they want a different username, well, they'll just have to register
a new account. But consider a website that has customized the account creation process so that instead of prompting the user for both a username and e-mail address, the user
is only asked to enter an e-mail address and that it is used as both their username and e-mail address on file. Anytime a user switched e-mail addresses - which can happen
when changing jobs, changing ISPs, or moving to the new, hip, web-based e-mail provider of the day - they need to also change their username on your site.
In order to change a user's username we'll need to bypass the Membership API and work directly with the user store. This article shows how to interface directly with the
SQL Server database schema used by the SqlMembershipProvider to change an existing user's username. Read on to learn more!
Read More >