Change user id globally

Apologies if this question has been asked (and answered) many times before, but I can't seem to find a satisfactory answer.

My company changed to a new LDAP directory server, and the old users where not mapped across. Usernames were changed too as part of the update (so, for example, johnd became jdoe). Unfortunately, since the old LDAP server no long exists, we now have tons of projects with invalid project leads and issues that have been reported, assigned to and commented upon by users that no longer exist.

Is there any easy way to remap an old LDAP user to a new LDAP user across the whole system (group memberships, project leads, reporters, assignees, commenters, etc.)?

2 answers

1 accepted

1 vote
Accepted answer
Pedro Souza Atlassian Team Jun 17, 2014

Hello,

One option would be taking a backup of your instance, and look directly into an XML backup file where you could try running a 'grep' or search to find every mention of a user (i.e. johnd) and replace it with the new user name (jdoe) and then restore the backup in a test instance, in order to confirm if all entries containing the old user name, now has the new user, then perform the search/replase for all users and test again in the test instance, if you confirm that all usersnames were changed as expected, you're good to import this backup to your production instance.

Cheers.

Hi Pedro,

Thanks for your suggestion. It wasn't as simple as I first thought (I had problems with the UserHistoryItemrecords in particular), but managed to get the updated data read in - and everything works as expected.

Thanks again!

Mike

0 votes
Chris Fuller Atlassian Team Jun 18, 2014

As long as you are on JIRA 6.0 or later (and with LDAP involved I would recommend using at least 6.1), you should be able to accomplish this by first letting it create the wrong user mappings and then modifying the app_user table to correct them. This will effectively make it look like all of your users were explicitly renamed from their old names to their new ones and everything should fall into place.

I'm not saying that this is a trivial or foolproof process; you will still have to figure out for yourself how the old user names map to the new ones. Where there are potential collisions, you will also have to make sure you do the updates in the correct order to avoid breaking unique constraints in the app_user table. For example, suppose you have these two people:

  • James Doe: old name is "james"; new name is "jdoe"
  • John Ames: old name is "john"; new name is "james"

Then you would need to move "james" to "jdoe" before you could move "john" to "james". Once you have planned out the full set of changes that you need to make and the right order to make them in:

  • Back up your JIRA installation. This is a good idea in general, but you're about to perform serious surgery on JIRA's data and you will want to be able to at least get back to where you were if this doesn't work out.
  • Shut down JIRA.
  • For each user that needs to be remapped, run: UPDATE app_user SET lower_user_name="newnamehere" WHERE lower_user_name="oldnamehere";
  • Note: As this suggests, if the username was in MixedCase before, you need to force it to lowercase for the purpose of these updates.
  • Once you've done all of these, start JIRA and see how things have worked out.

This will not solve *all* of your problems because renaming a user has certain limitations. In particular, any @ mentions or filters that reference specific users will remain broken. Good luck!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,664 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you