My company copied users from an AD database to a Jira Internal database. I now have literally thousands of "extra" user accounts for users who are Inactive and have never logged in to Jira. I would like to delete these users from the Jira Internal database. I have ScriptRunner, and simply need help with a script. Anyone willing to give it a shot and help me out?
I did try a script I found to at least strip their group assignments away, and although I got no errors, that script didn't work. All the Inactive users are all still assigned to various groups. Here's the info on that: https://community.atlassian.com/t5/Jira-questions/ScriptRunner-script-to-remove-inactive-users-from-all-groups/qaq-p/632587?utm_source=atlcomm&utm_medium=email&utm_campaign=immediate_general_reply&utm_content=topic#U2012433
Would really appreciate some guidance!
Hi @kdickason,
you can do it with this script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
def loginManager = ComponentAccessor.getComponent(LoginManager.class);
def adminUser = ComponentAccessor.userManager.getUserByName("admin") // Replace "admin" with an administrator username
def userUtil = ComponentAccessor.userUtil
ComponentAccessor.userManager.allUsers.each{ it->
if (loginManager.getLoginInfo(it.username).loginCount == null) {
log.error "User never logged in: " + it.username
//userUtil.removeUser(adminUser, it) // Uncomment this row to enable removal
}
}
This is wonderful for you to provide. But please allow me to ask -- what would I need to add to this script so it would only remove INACTIVE users who have never logged in? I would like to keep Active accounts who have never logged in for now. @Andrea Pannitti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@kdickason you could change the code like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
def loginManager = ComponentAccessor.getComponent(LoginManager.class);
def adminUser = ComponentAccessor.userManager.getUserByName("admin") // Replace "admin" with an administrator username
def userUtil = ComponentAccessor.userUtil
ComponentAccessor.userManager.allUsers.findAll{ !it.isActive() && loginManager.getLoginInfo(it.username).loginCount == null }.each{ it->
log.error "User inactive and never logged in: " + it.username
//userUtil.removeUser(adminUser, it) // Uncomment this row to enable removal
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @kdickason
I don't have a script but we are using Manage Inactive Users for Jira add-on to remove the never logged-in users from our system.
Thanks,
Tushar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.