Inactive users report

Run the following script in the Script Console in order to get the number of users that I) Belong in the given directory II) Belong in the given directory and have never logged in III) Belong in the given directory and in the given group IV) Belong in the given directory and in the given group and have never logged in

Requirements

Jira Jira (7.7 - 8.6)

    
import com.atlassian.crowd.manager.directory.DirectoryManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.security.login.LoginManager import static com.onresolve.scriptrunner.canned.util.OutputFormatter.markupBuilder final String directoryToCheck = "Jira Internal Directory" final String groupName = "jira-users" def loginManager = ComponentAccessor.getComponent(LoginManager) def directoryManager = ComponentAccessor.getComponent(DirectoryManager) def groupManager = ComponentAccessor.groupManager def userManager = ComponentAccessor.userManager def internalDirectoryId = directoryManager.findAllDirectories()?.find { it.name == directoryToCheck }?.id def jiraUsersGroup = groupManager.getGroup(groupName) // Get all users that belong to JIRA Internal Directory def allInternalDirectoryUsers = userManager.allApplicationUsers.findAll { it.directoryId == internalDirectoryId } // Get all the users that belong to JIRA Internal Directory and have never logged in def internalDirectoryUsersNeverLoggedIn = allInternalDirectoryUsers?.findAll { !loginManager.getLoginInfo(it.username).lastLoginTime } // Get all the users that belong to JIRA Internal Directory and to jira-users group def internalUsersBelongToGroup = allInternalDirectoryUsers?.findAll { groupManager.isUserInGroup(it, jiraUsersGroup) } // Get all the users that belong to JIRA Internal Directory and to jira-users group and have never logged in def jiraUsersHaveNeverLoggedIn = internalDirectoryUsersNeverLoggedIn?.findAll { groupManager.isUserInGroup(it, jiraUsersGroup) } markupBuilder { p("Users in Jira Internal Directory: ${allInternalDirectoryUsers?.size()}") p("Users in Jira Internal Directory and have never logged in: ${internalDirectoryUsersNeverLoggedIn?.size()}") p("Users in Jira Internal Directory and in jira-users group: ${internalUsersBelongToGroup?.size()}") p("Users in Jira Internal Directory and in jira-users group and have never logged in: ${jiraUsersHaveNeverLoggedIn?.size()}") }
Discovered an issue? Report it here

Suggested for you