Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira user management - Disabling the inactive users with no activity for past 90 days

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. 

 

3 answers

2 accepted

1 vote
Answer accepted
Ben Poulson Community Leader Jun 04, 2019

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}"
}
}
}

@Ben Poulson Thanks Ben. Let me test this and update on this thread.  

Is it working ? if no then, is there any way from SQL DB to achieve this result ? 

0 votes
Answer accepted
Petr Vaníček Community Leader Jun 04, 2019

Hi,

in that case I have experience with this add-on for Jira. Disabling of inactive users is only one of features.

https://marketplace.atlassian.com/apps/1217194/optimizer-for-jira-cleaner-for-jira?hosting=server&tab=overview

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?  

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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you