Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Map Internal user to LDAP users

Prashant Sangappa Shivashimpi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2022

Hi All,

We are migrating projects from one JIRA instance to Our JIRA instance both are on Server and version 8.x. The username in source instance are in form of 1234***** number format and this is the login ID in source instance. On target instance, we have username as email ID and the login ID is email ID.

So we have both users present in our instance now. The 1234***** as JIRA Internal User and user email ID as LDAP authenticated user.

The JIRA tickets are assigned to 1234***** user and we need to migrate this to user with email ID as login.

We are using Config Manager and tried the approach to perform selective merge. This is taking lot of time and process is longer than expected.

Could you please help in getting this checked and provide some insights.

 

Thanks in advance for your time.

 

BR,

Prashant.

1 answer

1 accepted

0 votes
Answer accepted
Tom Lister
Community Champion
August 8, 2022

Hi 

If you're feeling brave you can try my SQL solution from a while back.

https://community.atlassian.com/t5/Atlassian-Migration-Program/Jira-LDAP-Migration-using-SQL/ba-p/942752

May need revisiting in terms of DB schema. DB work is high risk.

If you have scriptrunner this switches assignees and reporters. Comment authors is a bit more complicated.



/*****************************************
Tom Lister 2021
 
******************************************/
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
 
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.bc.issue.IssueService
//import com.atlassian.jira.bc.issue.IssueService.IssueValidationResult
import com.atlassian.jira.bc.issue.IssueService.UpdateValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
def logit = Logger.getLogger("com.cheil.eu.logging")
 
// **********************************************
// user replacements
// **********************************************
// key : value
def users = [
"blah.h@cheileu.com":"blah.h@cheil.com",
"who.ml@cheileu.com":"who.ml@cheil.com"
// etc,
]
 
String oldUser
String newUser
String assigneeclause1 = 'assignee in ( "'
String reporterclause1 = 'reporter in ( "'
String clause2 = '")'
 
// set true to add key (lefthand value), set false to add value (righthand value)
boolean adduser = true
def jqlSearch
List<Issue> issues = null
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
UserManager userMgr = ComponentAccessor.getUserManager()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()
 
IssueService issueService = ComponentAccessor.issueService
 
def searchResult
 
users.each() {
if (adduser) {
oldUser = it.key
newUser = it.value
} else {
oldUser = it.value
newUser = it.key
}
// ASSIGNEE
jqlSearch = assigneeclause1 + oldUser + clause2
logit.info( "" + jqlSearch)
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
StringBuffer sBuf1 = new StringBuffer()
searchResult.getResults().each { issue ->
sBuf1.append(issue.getKey() + ", ")
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setSkipScreenCheck(true);
issueInputParameters.setAssigneeId(newUser)
UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, issue.id, issueInputParameters);
if (updateValidationResult.isValid())
{
IssueResult updateResult = issueService.update(user, updateValidationResult);
if (!updateResult.isValid())
{
sBuf1.append("Y, ")
}
}
}
logit.info(sBuf1.toString())
} else {
logit.error("Invalid JQL: " + jqlSearch);
}
// REPORTER
jqlSearch = reporterclause1 + oldUser + clause2
logit.info( "" + jqlSearch)
SearchService.ParseResult parseResult2 = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
searchResult = searchService.search(user, parseResult2.getQuery(), PagerFilter.getUnlimitedFilter())
//logit.info(searchResult.getResults().size())
StringBuffer sBuf2 = new StringBuffer()
searchResult.getResults().each { issue ->
sBuf2.append(issue.getKey() + ", ")
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setSkipScreenCheck(true);
issueInputParameters.setReporterId(newUser)
UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, issue.id, issueInputParameters);
if (updateValidationResult.isValid())
{
IssueResult updateResult = issueService.update(user, updateValidationResult);
if (!updateResult.isValid())
{
sBuf2.append("Y, ")
}
}
}
logit.info(sBuf2.toString())
} else {
log.error("Invalid JQL: " + jqlSearch);
}
}


Prashant Sangappa Shivashimpi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2023

Hi Tom,

Greetings. Thank you very much.! The approach provided in your link looks good. 

BR,

Prashant.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.7
TAGS
AUG Leaders

Atlassian Community Events