Koozali.org: home of the SME Server

How can I change an account name?

Offline joerg

  • 4
  • +0/-0
How can I change an account name?
« on: February 20, 2018, 04:37:09 PM »
Hallo,

I would like to change a user's account name (the user's lastname changed when she married).
The user-panel in the server-manager seems to have no option for that.

usermod and groupmod at the command-line managed to assign new names to the uid and gid (as expected), but obviously do not do the whole job on the SME server, as the user-panel still shows the old account name.

Do I have to remove the old account and create a new one? But I don't want to loose the user's directory (especially the Maildir).

Actually, I don't regard changing an account name as very exotic. Or is it?
Maybe someone can suggest a step-by-step procedure.

Many thanks and
kind regards,

Jörg Schaldach


Offline Stefano

  • *
  • 10,836
  • +2/-0
Re: How can I change an account name?
« Reply #1 on: February 20, 2018, 05:26:53 PM »
you can't change the username but you can change First and Last name without problems
moreover, you can create a pseudonym in whichever form you need for the username.

that said, can you please give us more details?
thank you in advance

Online Jean-Philippe Pialasse

  • *
  • 2,747
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: How can I change an account name?
« Reply #2 on: February 20, 2018, 05:34:48 PM »
it is unusual. To complete Stefano's answer:

Usually you will rather keep the user name ( she can get a divorce, even if we do not wish that to her and wish her to enjoy her new life)

You can create a pseudonyme to morph the email, and then keep the two emails fucntional in case some emails still arrive to her old name, and believe me you will get some for the next years .

By using usermod + groupmod you desynch the two db (accounts db and pam db)
now you have a user existing on the unix system  and another existing on the account db and they share the same uid and gid, thiw will create unexpected behaviour

ideally you would have avoided this situation by no using these tools.

From here,  there are multiple ways to work:

-use again the tools in a reverse direction, and do one of the following:
-- create new account and transfer files, fix ownership (you can use find for uid and gid and pipe to chown the files), delete old account
-- keep the current account if she is not bohtered to keep it as a login ( I have plenty user set with a login different from their main email address) and set a pseudonyme with her new name to point to her box.

- go on with the current situation:
-- manually edit the accounts db file /home/e-smith/db/accounts to change the user name. group name is not used , but rather gid in the db so you do not have to worry about.

 for info shadow / group /password allow to have multiple username groupname with same uid/gid/ For example we set www and apache with the same id. I am not sure if it would work for auth like with ssh, pop, imap, smpt etc...


AS you see there are multiple way to do, choose what seems the more feasable for you, considering the different way to do one could be chosen as a contrib for a specific need where the pseudonym workaround is not accepted, and create new account, migrate is too complexe.

Offline joerg

  • 4
  • +0/-0
Re: How can I change an account name?
« Reply #3 on: February 20, 2018, 06:19:32 PM »
Thank you very much for your very fast answers!

I reversed the use of usermod and groupmod already, to keep the system consistent.

I guess I will go for a new account and transfer the files.

In general, I think that for example Susan Miller would prefer to login in as smiller and not as ssmith...

Thanks again,
Jörg



Online Jean-Philippe Pialasse

  • *
  • 2,747
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: How can I change an account name?
« Reply #4 on: February 20, 2018, 07:43:40 PM »
In general, I think that for example Susan Miller would prefer to login in as smiller and not as ssmith...

Thanks again,
Jörg

you never Know ! Ask do not assume. My wife has kept her name for daily use at work. Also it change from a country to another.

but yes I understand it is important to ask.