Batch change usernames

Hi all,
I need to change “username” on all users on a cryosparc master server, because they were originally set as fullnames, but needs to be changed to linux usernames.
One can do this with “cryosparcm updateuser” command, but this requires one to know the password of each user.
@stephan says this is a security thing: Cryosparcm updateuser requires knowing a user's password
But I do not quite get that, because one can easily reset any users password with the “cryosparcm resetpassword” without knowing there previous password.

Is there any other way to change “username” field of each user in a batch/cli mode without the need to reset or know users password?

Best regards,
Jesper

Hi,

You can use the MongoDB shell to update usernames without using the cryosparcm updateuser command:

  1. Enter the MongoDB shell via cryosparcm mongo
  2. Run the following command (change email and username):
db.users.update({ 'emails.0.address': 'email@domain.com' }, { $set: { name: 'newusername' } })
  1. Repeat this command for all users you would like to update, then exit the shell by typing exit

- Suhail

1 Like

Brilliant!
Just what I was looking for.

Thanks @sdawood

//Jesper