Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

$4.95 Windows Hosting at Webhost4life.com
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Biz Modules provides professional business modules and solutions for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
MadCap Software, Inc.
AspDotNetStoreFront - E-Commerce by Design - The Leading ASP.NET shopping cart platform for developers!
Click here to go to dev.live.com for Windows Live developer resources
SteadyRain
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Configure It! (...  Allowing users to change username?
Previous Previous
 
Next Next
New Post 4/18/2008 5:16 AM
User is offline Steve Malkin
11 posts
10th Ranked


Allowing users to change username? 

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 7:28 PM
User is offline Will Strohl
1271 posts
www.strohlsitedesign.com/
6th Ranked


Re: Allowing users to change username? 

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 LinkedIn profile
StrohlSiteDesign.com | My Blog | DotNetNuke® Skins by SSD
Google Toolbar Button for DNN | Suggested DNN Upgrade Paths
ODUG Web Site
 
New Post 5/15/2008 2:04 AM
User is offline Leif Arne Brekke
3 posts
10th Ranked


Re: Allowing users to change username? 
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 5:58 AM
User is offline Paul Deschenes
102 posts
9th Ranked


Re: Allowing users to change username? 

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 8:10 AM
User is offline Will Strohl
1271 posts
www.strohlsitedesign.com/
6th Ranked


Re: Allowing users to change username? 

 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 LinkedIn profile
StrohlSiteDesign.com | My Blog | DotNetNuke® Skins by SSD
Google Toolbar Button for DNN | Suggested DNN Upgrade Paths
ODUG Web Site
 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Configure It! (...  Allowing users to change username?
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


AfterImage Internet Consulting and SEO Services
AfterImage provides search engine optimization (SEO), Internet consulting and hosting services for the Windows platform (IIS, ASP, SQL Server).
www.afterimage.nl/
Willhite & Sharron Realtors
Exemplary service for your Seattle Real Estate needs. It's what you deserve from your Realtor®!
www.alkihomes.com
Swanzey Internet Group LLC
DotNetNuke design, development, hosting, maintenance, and training. Translation of conventional (non-DNN) sites welcomed. Cleanup of existing DNN sites welcomed.
www.swanzey.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP