Forums

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

Change user

Peter Cselotei - Lupus Consulting Zrt_
Contributor
January 9, 2020

Dear All, 

I have the following question: one of our user working for years in JIRA. Now he's got a new AD user, wich means new JIRA user. But the problem is, that of course every object (worklogs, assigned tickets, filters, permissions, roles ect) remains at his older user.

Do you know any addon, script, anything, that we can user, to 'change' his old user objects ownership to the new user?

I know, scriptrunner has a part, that can change the ownership of filters and dashboards. That' a good start, but absolutely not enough. Changing every role, permission, assigne would take weeks (although, we would be never sure, if it's fully completed), also the worklogs owner cannot be changed this way.

 

I'm hoping for any kinf of help :)

 

Best: Peter

1 answer

1 accepted

0 votes
Answer accepted
Tom Lister
Community Champion
January 9, 2020

Hi @Peter Cselotei - Lupus Consulting Zrt_ 

If your confident with SQL and the Jira database you could try some of the tricks in this article.

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

Tom

Peter Cselotei - Lupus Consulting Zrt_
Contributor
January 22, 2020

Hi @Tom Lister  and thanks for answering.

Unfortunately I have no access to the database (security reasons), also I hardly think that any further answer will come, so I accept this answer, and still hope, some script or addon may come up in the future.

 

Thanks!

Best: Peter

Tom Lister
Community Champion
January 22, 2020

Hi @Peter Cselotei - Lupus Consulting Zrt_ 

I’ll see if I have any useful groovy scripts.

Tom

Tom Lister
Community Champion
January 24, 2020

Hi @Peter Cselotei - Lupus Consulting Zrt_ 

FYI

we have this script as a start point for updating comments. When I ran it didn't update but I can't see why from the API notes.

It needs ScriptRunner installed for the JQL query function

 


import com.atlassian.jira.issue.comments.MutableComment
import com.atlassian.jira.issue.comments.Comment
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

def log = Logger.getLogger("com.cheil.logging")

// **********************************************

// **********************************************
String oldUser = "old@domain.com"
String newUser = "new@domain.com"
def jqlSearch = 'issueFunction in commented("by ' + oldUser + '")'
List<Issue> issues = null
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def userUtil = ComponentAccessor.getUserUtil()
def commentMgr = ComponentAccessor.commentManager
UserManager userMgr = ComponentAccessor.getUserManager()
ApplicationUser newAppUser = userMgr.getUserByName(newUser)
List<Comment> comments
MutableComment mut
IssueManager issueManager = ComponentAccessor.getIssueManager()

SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
// searchService.search()
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())

searchResult.getResults().each { issue ->
def issueData = issueManager.getIssueObject(issue.id)
log.info (issueData.key)
comments= commentMgr.getCommentsForUser(issueData, user)
comments.each {comment ->
if (commentMgr.isUserCommentAuthor(user, comment)) {
log.info("author: " + comment.getAuthorApplicationUser())
mut=commentMgr.getMutableComment(comment.getId())

mut.setAuthor(newAppUser)
try {
commentMgr.update(mut, true)
} catch (Exception e)
{
log.info(e.getMessage())
}
log.info("newAuthor: " + mut.getAuthorApplicationUser())
}
}
}
// issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
} else {
log.error("Invalid JQL: " + jqlSearch);
}

Peter Cselotei - Lupus Consulting Zrt_
Contributor
February 11, 2020

Thank you!! :)

Rodolfo So June 15, 2022

I will try this one.thanks

Suggest an answer

Log in or Sign up to answer