Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How do I merge duplicate users?


I have setup JIRA hosted in Linux server (On Prem), connected to an external Microsoft Active Directory LDAP and now my client has moved the instance to AWS cloud, connected to same Microsoft Active Directory with SAML authentication or MFA.

However, the username format is not same. The on prem instance is using the AD enterprise username as username while the AWS is using the AD email as username. After using the Configuration Manager tool/plugin to capture a snapshot from the on prem instance and deploy to the AWS instance, same user is having two accounts. Also, content ownership, issue association and permissions are not being migrated to the new username.

Using "Charlie Atlassian" as the example user, in the original directory his username is "catlassian", but in the new directory it will be "". I want to make sure that once I have migrated projects from the on prem instance to AWS instance, I want Charlie's username should merge to the aws username format, therefore Charlie should only have one username. Also, I want content ownership, issue association and permissions from on prem instance migrated to the new username in aws. I have written the below script using Scriptrunner and I am getting “user already exist with same user name” error message.

import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor

def userManager = ComponentAccessor.userManager
def userService = ComponentAccessor.getComponent(UserService)
def userSearchService = ComponentAccessor.getComponent(UserSearchService)


// add more as required by separating them in a comma (,)
].each { username ->
//def username = userSearchService.findUsersByEmail(userEmail.toString()).iterator().next().getKey()
def user = userManager.getUserByName(username)
if (!user) {
log.warn "Could not find user ${username}"

def updatedUser = userService.newUserBuilder(user).name("").build()

def updateUserValidationResult = userService.validateUpdateUser(updatedUser)

if (updateUserValidationResult.isValid()) {
log.warn "Updating user ${username}"
} else {
log.warn "Update of ${} failed: ${updateUserValidationResult.errorCollection.errors.entrySet().join(',')}\n"

Merging user error.JPG

Above error in the picture above is what I get when I run the code snippet I have

Ideally I want the script to identify duplicate users with the same email address, merge the users and make the emails their username. Based on my research, simply adding the new directory then disabling the original directory will not transfer over issue associations.


1 answer

0 votes
Benjamin Community Leader Jul 23, 2021

@Andi Zhou 


Done something like this a while back. Since you are using configuration manager, you can modify the snapshot by swapping our the users to the users you want. But first, you need to create a mapping table to figure which users are map to those particular e-mail address and then apply script to swap. Then when you deploy the snapshot, the new users will take into account with the username as e-mail addresses.


Hope this helps.

Thanks for the reply Benjamin! Did that method carry over the issue associations?

Benjamin Community Leader Jul 26, 2021

You welcome. As I recall, yes. The newly mapped users will replace the previous users of those associated tickets.


Am having a similar task and would appreciate you expanding further.

Are you suggesting that once the snapshot has  been captured, the usernames can be changed in the snapshot before deploying to the target instance? 

Or  are you suggesting that the users be identified and the script ran in the source instance to modify the identified users before the snapshot is captured?

Please help Newbies understand the best approach here.


Benjamin Community Leader Aug 29, 2021

Hi @Philemon Nkafu ,


Ideally, you should have a table of where those users would be mapped.


capture a snapshot. Then open the file and make the modification with either a script or a tool of choice. Then close the snapshot and then deploy it at the destination.



Suggest an answer

Log in or Sign up to answer

Atlassian Community Events