HomeHomeUsing DotNetNuk...Using DotNetNuk...Administration ...Administration ...Change Username in DNNChange Username in DNN
Previous
 
Next
New Post
3/29/2006 9:55 PM
 

Hi ,

         I am using DNN 3.0.13 is there is any way to change/update the username for users ?

Thanks

Vibul

 
New Post
5/16/2006 9:27 AM
 
I have the same question. Did you ever get an answer to this one??
 
New Post
5/16/2006 9:29 PM
 

Yes i got the answer !!

you need to update in Database using following query


update users set username='newusername' where username='oldusername'


update aspnet_Users set username='newusername' ,loweredusername='newusername' where username='oldusername'

 

Thanks

Vibul

 

 
New Post
5/17/2006 7:19 AM
 

Awesome Thanks for the reply. I actually figured it out myself and by the looks of it I did it the exact same way that you did. We must be smart!!

Thanks again

 
New Post
7/19/2006 2:53 PM
 

If you are going to make this repeatable, you might want to wrap the logic in a transaction. You wouldn't want the two tables to be out of sync. Here is a sample as series of T-Sql statements. Should be easy to convert to a stored proc:

 

declare @oldName nvarchar(128)
declare @newName nvarchar(128)
declare @error_var int, @rowcount_var int
declare @newNameCount int

select @oldName = 'johndoe1'
select @newName = 'johndoe2'


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


WildVoice.com Michael Levy - Are you ready to be heard? WildVoice.com
 
Previous
 
Next
HomeHomeUsing DotNetNuk...Using DotNetNuk...Administration ...Administration ...Change Username in DNNChange Username in DNN


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.

Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

DotNetNuke Scoop!

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.