Forums

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

How we can get the users last login timestamp in Jira. By using saml account with api token?

Ajinkya Bele October 28, 2024

I have an enterprise account please suggest the possible ways

2 answers

1 vote
Evgenii
Community Champion
October 28, 2024

Hi, @Ajinkya Bele 

Welcome to Atlassian Community

If you have ScriptRunner, you can use it, to get users last login dates.

When I had a similar tasks, to collect list of inactive users, I made such script, which retrieves last login dates:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
import com.atlassian.jira.bc.security.login.LoginInfo

// Method to get LoginInfo by username
LoginInfo getLoginInfoByUsername(String userName) {
LoginManager loginManager = ComponentAccessor.getComponent(LoginManager)
return loginManager.getLoginInfo(userName)
}

// Fetch last login time for a specific user
def userName = "your_username_here" // Replace with the actual username
def lastLoginTime = getLoginInfoByUsername(userName)?.lastLoginTime
Ajinkya Bele October 28, 2024

thanks for the reply but i want to extract last login activity via api token and my jira server is hosted in aws using saml account i want to get the information is it possible?

Evgenii
Community Champion
October 31, 2024

I'm sorry, but I'm having trouble understanding your point. Let me clarify:

  • AWS is simply the service where Jira is deployed.
  • SAML is an authentication method that can be integrated with Jira.

By default, Jira doesn't provide a method to retrieve the time when a user last logged in. The REST API doesn't support this information.

Regarding SAML, I'm not sure it can provide the timestamp of a user's last login. Since SAML is an AWS service and not part of Jira, the login time information is stored within Jira itself.

Like Steffen Opel _Utoolity_ likes this
0 votes
Ajinkya Bele October 30, 2024

@Evgenii apart from scriptrunner is there any way to extract last login activity via api token and my jira server is hosted in aws using saml account i want to get the information is it possible?

Suggest an answer

Log in or Sign up to answer