Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Extract all users with last login time stamp - Jira DC

Nag
Contributor
February 1, 2024

Hello there,

 I’m trying to extract all Jira users with with below details

user name, full name, email id, status and last login time stamp

Using JIRA Data center and script runner, below is my script

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

def userManager = ComponentAccessor.getUserManager()
def users = userManager.getAllApplicationUsers()

def userList = users.collect {
[
userId: it.key,
fullName: it.displayName,
emailAddress: it.emailAddress,
active: it.active,
lastLoginMillis: it.lastLoginMillis
]
}

// Print the user list (you can modify this to export to Excel)
userList.each { user ->
def lastLogin = user.lastLoginMillis ? new Date(user.lastLoginMillis) : null
println("User ID: ${user.userId}, Full Name: ${user.fullName}, Email: ${user.emailAddress}, Active: ${user.active}, Last Login: ${lastLogin}")
}

 

 

However I get this error

No such property: lastLoginMillis for class: com.atlassian.jira.user ApplicationUser

 

I really appreciate your suggestion on how can I fix this

3 answers

0 votes
Aron Gombas _Midori_
Community Champion
February 2, 2024

I am not sure if you have to use ScriptRunner. If not, then you can export all user accounts to  an Excel spreadsheet like this:

jira-user-export.pngIt is created with a few clicks in Better Excel Exporter. You can install the app and export this data set using a trial license.

(Discl. it is a paid and supported app developed by our team. Free for 10 users.)

0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 1, 2024

You can't, because there isn't such a property for ApplicationUser, much like the error suggests.

I'm more curious how you came to try getting it from the user object, as in, why.

 

Anyhoo, for that there is this interface:

https://docs.atlassian.com/software/jira/docs/api/9.4.11/com/atlassian/jira/security/login/LoginManager.html

With which you can #getLoginInfo(String username); and from LoginInfo you can then get the login related data.

 

Having said all of that, there is a kba from Atlassian for this: https://confluence.atlassian.com/jirakb/find-the-last-login-date-for-a-user-in-jira-server-363364638.html

 

0 votes
Mirek
Community Champion
February 1, 2024

Hi @Nag 

If you have a problem with last login and timestamp please look at this question 

https://community.atlassian.com/t5/Jira-Software-questions/How-to-get-a-user-s-login-details-with-scriptrunner/qaq-p/2347945

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events