Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Allowing users to change username?Allowing users to change username?
Previous
 
Next
New Post
4/18/2008 8:16 AM
 

The standard profile page doesn't allow users to change their username, only their e-mail, display name etc.

I have imported a large number of user accounts into DNN from a previous application, and the imported users have their usernames set to be the same as their e-mail address (because thats how they used to log onto the old application)

I wanted a way for these users to be able to change their usernames if they wanted to, and I have written a simple module that I can drop onto a page beside the user accounts module that will allow them to do that.

Before I implement this, I wanted to check whether anyone knew of any good reason not to do it.

It seems like such a simple thing to do that I thought there must be some good reason why the ability to change username was not included in the framework as standard.

Will I encounter some horrible database corruption somewhere down the line if I allow changing of usernames?

Thanks

Steve

PS.

The module I have written simply makes a call to the following stored procedure to do the change, passing in the old and new username as parameters.

CREATE PROCEDURE ChangeUsername
 
@oldName nvarchar(128),
@newName nvarchar(128)

AS

declare @error_var int, @rowcount_var int
declare @newNameCount int

begin transaction

 select @newNameCount = count(*)
  from Users
  where Username = @newName
 if @newNameCount > 0
 begin
  RAISERROR('Username already exists. @newName=%s', 10, 1, @newName)
  ROLLBACK TRANSACTION
  RETURN
 end

 update Users
 set Username = @newName
 where Username = @oldName
 
 SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT
 IF @rowcount_var <> 1 OR @error_var <> 0
 BEGIN
  RAISERROR('Could not Update User.Username. @oldName=%s', 10, 1, @oldName)
  ROLLBACK TRANSACTION
  RETURN
 END
 
 
 update aspnet_Users
 set
  Username = @newName,
  LoweredUserName = LOWER(@newName)
 where LoweredUserName = LOWER(@oldName)
 
 SELECT @error_var = @@ERROR, @rowcount_var = @@ROWCOUNT
 IF @rowcount_var <> 1 OR @error_var <> 0
 BEGIN
  RAISERROR('Could not Update aspnet_Users.Username. @oldName=%s', 10, 1, @oldName)
  ROLLBACK TRANSACTION
  RETURN
 END

Commit transaction
GO

 

 
New Post
4/20/2008 10:28 PM
 

You will need to try this, as the DNN DB uses the Username property as a key.  In my applications where I have had to do the same thing, I have done this through the use of a custom Membership and Profile Provider.  However, if it works, there is no reason to not do it.  But beware on future DNN upgrades...  You will want to retest this functionality thoroughly before upgrading.


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
5/15/2008 5:04 AM
 
Have you tried this out? I have a site where I want to change some of the usernames but am a little worried about issues that might arise.
 
New Post
5/15/2008 8:58 AM
 

I have done this since version 4.3.x. No issues. It was really quite simple, to my surprise, and presents no issues, at least in my dnn application. I should note that I do not use any of the DNN core modules, other than TEXT/HTML and Account Login, so I can't speak for what else depends on username. I've created a situation in my application where the username is always equal to the users.email value and when that gets changed, so too does the users.username value and the relevent fields in the aspnet_XXX tables.

 
New Post
6/23/2008 11:10 AM
 

Paul Deschenes wrote

I have done this since version 4.3.x. No issues. It was really quite simple, to my surprise, and presents no issues, at least in my dnn application. I should note that I do not use any of the DNN core modules, other than TEXT/HTML and Account Login, so I can't speak for what else depends on username. I've created a situation in my application where the username is always equal to the users.email value and when that gets changed, so too does the users.username value and the relevent fields in the aspnet_XXX tables.

I have done something similar to what you have described.  This is still best done by creating a custom provider (with a new name and everything), based on the default DNN provider.  Initially, you can copy and paste it as a new project.  Then, just change what you need (e.g., overriding the username using the given email address in the CreateUser method).


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Allowing users to change username?Allowing users to change username?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out