Forums

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

Get user status via Scriptunner

Patrick Vanhoof
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 28, 2022

I have a script that lists the users of group confluence-users. Snippet:

 

users.each { userName ->
def user = userAccessor.getUserByName(userName)

if (user) {

def loginInfo = loginManager.getLoginInfo(user)
def lastSuccessfulDate = convertDate(loginInfo?.lastSuccessfulLoginDate)
def lastFailedDate = convertDate(loginInfo?.lastFailedLoginDate)

log.warn "${user.fullName};${user.name};${lastSuccessfulDate};${lastFailedDate}"
}
}

 

I also want the user state to be logged (disabled or not), but can't find how to do that.

All help appreciated!

1 answer

1 accepted

0 votes
Answer accepted
Mohamed Benziane
Community Champion
February 28, 2022

Hi @Patrick Vanhoof 

You can try this

if (user) {

def loginInfo = loginManager.getLoginInfo(user)
def lastSuccessfulDate = convertDate(loginInfo?.lastSuccessfulLoginDate)
def lastFailedDate = convertDate(loginInfo?.lastFailedLoginDate)

def isActive = user.isActive()//false user is deactivate

https://docs.atlassian.com/software/jira/docs/api/7.1.9/com/atlassian/jira/user/ApplicationUser.html#isActive-- 

Patrick Vanhoof
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 28, 2022

Hi @Mohamed Benziane ,

Thanks.

But you are referring to the Jira docs, I am trying to list Confluence users. 

isActive does not seem to exist for the class I use:

[Static type checking] - Cannot find matching method com.atlassian.confluence.user.ConfluenceUser#isActive().

Regards,

Patrick

Like Patrick Vanhoof likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events