Hello all,
We got several spam accounts in our internal directory with same full name. We need to bulk delete all of them.
Is there a way we could get list of Users using full name and deleting them using a loop in ScriptRunner?
Hello @kiran kumar
Try the following
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.component.ComponentAccessor
def userServise = ComponentAccessor.getComponent(UserService)
def userSearchServise = ComponentAccessor.getComponent(UserSearchService)
def adminUser = ComponentAccessor.userManager.getUserByName('AdminUserName')
def users = userSearchServise.findUsersByFullName('FullName')
users.each {
def result = userServise.validateDeleteUser(adminUser, it)
if (result.valid) userServise.removeUser(adminUser, result)
}
Thanks a lot, Yuri!
Just one correction, getUserByName did not work, so I have used getUserByKey.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.