[SCRRIPT RUNNER] CrowdService User Directory

Maciej Olszewski November 21, 2016

 Hello,

I try to find inactive users from one of our 3 User Directories that aren't in our "notused" group. For now my script looks like this

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.crowd.embedded.api.CrowdService
import com.atlassian.crowd.embedded.core.util.StaticCrowdServiceFactory

UserUtil userUtil = ComponentAccessor.getUserUtil()
CrowdService crowdService = StaticCrowdServiceFactory.getCrowdService()

result = "<table style=\"width:100%\">"
userUtil.getUsers().findAll{!it.isActive()}.each{ user ->
    
    if (!crowdService.isUserMemberOfGroup(user.getName(), "notused")){
    	result += "<tr><th>" + user.name + "</th>" + "<th>" + user.displayName + </th>" + "<th>" + user.emailAddress + "</th>" + "</th></tr>"
        }
}
result += "</table>"
result

But i don't know (and can't find) how to check if user is in target user directory.

Thanks in advance,
Maciej O. 

1 answer

1 accepted

0 votes
Answer accepted
Vasiliy Zverev
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.
November 21, 2016

Try this code to get DirectorId:

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

for(ApplicationUser user: ComponentAccessor.getUserManager().getAllApplicationUsers()){
    user.getDirectoryId()
}
Maciej Olszewski November 21, 2016

Thank you! smile

Suggest an answer

Log in or Sign up to answer