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 ...Change a userChange a user's username?
Previous
 
Next
New Post
7/30/2008 11:02 AM
 

Hi There,

I have a client who would like to be able to change a user's username somehow.  He only wants the administrators to have this feature, if possible.

Is it possible in DNN to for a user's username to be changed?  I couldn't figure out a way to do it.

  -Josh

 
New Post
7/30/2008 1:05 PM
 

As far as I can tell, it's not built in. Everything else in here is based on my knowledge of what I've done to change the username in the past that has worked.

There are two tables in the DB that need to be modified to change the user name.

Users and aspnet_Users. I don't have a database open ATM, but I think there are 3 places in the 2 tables it needs to be changed. Doing so has successfully changed the username in the past for me.

Be careful when doing this and note that one of the usernames is a lowercase version of it. I've never tried not lowercase to see what happens. :)

If you do make a module, or get one from someone, ect - Make sure the new UserName is matches the same criteria for the original. That the module is secured against SQL Injection attacks, ect. It seems like such a quick little module, but here are a lot of potential little things that need to be covered. I'm lazy, and have never sat down to do that stuff to make it myself.

 
New Post
8/1/2008 7:26 PM
 

Hi,

This is the sp that we use to do this

 ALTER PROCEDURE dbo.ChangeDNNUserName
@oldName nvarchar(100),
@newName nvarchar(100)
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
  ROLLBACK TRANSACTION
  RAISERROR('Username already exists. @newName=%s', 11, 1, @newName)
  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', 11, 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', 11, 1, @oldName)
  ROLLBACK TRANSACTION
  RETURN
 END
Commit transaction
RETURN

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Change a userChange a user's 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