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
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
Hi @kdickason,
you can do it with this script:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.security.login.LoginManagerdef loginManager = ComponentAccessor.getComponent(LoginManager.class);def adminUser = ComponentAccessor.userManager.getUserByName("admin") // Replace "admin" with an administrator usernamedef userUtil = ComponentAccessor.userUtilComponentAccessor.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
@kdickason you could change the code like this:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.security.login.LoginManagerdef loginManager = ComponentAccessor.getComponent(LoginManager.class);def adminUser = ComponentAccessor.userManager.getUserByName("admin") // Replace "admin" with an administrator usernamedef userUtil = ComponentAccessor.userUtilComponentAccessor.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}
It looks like you're new here. Sign in or register to get started.