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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,457,939
Community Members
 
Community Events
176
Community Groups

How do I merge duplicate users?

Edited

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 "charlie.atlassian@domainname.com". 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
import com.atlassian.jira.bc.user.search.UserSearchService

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

[
'testusername',

// 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}"
return
}

def updatedUser = userService.newUserBuilder(user).name("PavanKumar.Chityala@dhs.arkansas.gov").build()

def updateUserValidationResult = userService.validateUpdateUser(updatedUser)

if (updateUserValidationResult.isValid()) {
log.warn "Updating user ${username}"
userService.updateUser(updateUserValidationResult)
} else {
log.warn "Update of ${user.name} 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.

@Benjamin 

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.

Thanks 

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.

 

-Ben

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events