Hi All,
We are using Jira - 7.7.4 (Commercial - Data Center) [Approximately 4000 users]
[Update 8.2.1 is available]
Use case - We want to delete the inactive users(not looged in since last 90 days) from the system.
Problem - Currently Jira shows that all my 4000 users are active (this also includes the users which never logged in)
Reason - We only have a limit for 5000 users and we cant add any more users once we reach that limit.
Does Jira already has support for this to do it via REST API? OR We need to create an automation script for this to filter and delete the users from backend?
Suggestions are welcome if anyone has already explored on this problem.
Wrote a groovy script to do it- if you have scriptrunner installed, you can set it as an escalation service to run on whatever schedule you want
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.UserService
import com.atlassian.crowd.embedded.impl.ImmutableUser
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.security.login.LoginManager
import com.atlassian.jira.bc.security.login.LoginInfo
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.crowd.embedded.api.User
UserManager userManager = ComponentAccessor.getUserManager()
def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
UserService userService = ComponentAccessor.getComponent(UserService)
ApplicationUser updateUser
UserService.UpdateUserValidationResult updateUserValidationResult
def users = userManager.getUsers().findAll{user -> (user.isActive())}
for (user in users)
{
def lastLoginMillis = loginManager.getLoginInfo(user.name).getLastLoginTime()
def disable = false
if(!lastLoginMillis)
{
//user has never logged in
disable = true
}
else
{
Date cutoff = new Date().minus(90)
Date last = new Date(lastLoginMillis)
if(last.before(cutoff))
{
disable = true
}
}
if(disable == true)
{
def userAsImmutable = new ImmutableUser(user.directoryId, user.name, user.displayName, user.emailAddress, false)
updateUser = ApplicationUsers.from(userAsImmutable)
updateUserValidationResult = userService.validateUpdateUser(updateUser)
if (updateUserValidationResult.isValid())
{
userService.updateUser(updateUserValidationResult)
log.info "Deactivated ${updateUser.name}"
}
else
{
log.error "Failed to deactivate ${updateUser.name}"
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it working ? if no then, is there any way from SQL DB to achieve this result ?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
in that case I have experience with this add-on for Jira. Disabling of inactive users is only one of features.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Petr Vaníček This is really useful but ideally I would like to call a REST API to delete these users from my automation script so that I can run it at the predefined time interval without any human intervention.
Do you have any working example to do this activity via REST calls?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Darshan Deshmukh ,
This is Mahima from miniOrange.
If you are looking for plugin which can fulfill your requirements, I would like to suggest you User Management Plugin which can automatically deactivate the users who have never logged in or who have not been active since past 90 days or any other time period, which can help you to manage your users easily in just one click.
Feel free to reach out to us at atlassiansupport@xecurify.com or you can raise the ticket in case you need any help!
Cheers,
Mahima
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.