Forums

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

Find all Users that not have "Jira Software" as Applications

Frank Lohfeld April 19, 2023

Hello,

i need a Script that list and activate all users in my jira instance that don't have "Jira Software" as Applicatons in User Keys 

My script 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.util.DefaultUserManager

def userManager = ComponentAccessor.getUserManager()
def userUtil = ComponentAccessor.getComponent(UserUtil)

// Get all Jira users
def allUsers = userManager.getAllUsers()

allUsers.each { user ->
def userKeys = userUtil.getUserKeysForUser(user)
if (!userKeys.contains("jira-software")) {
// Update the user to activate it
def mutableUser = userManager.getUserByName(user.getName())
mutableUser.setActive(true)
DefaultUserManager.updateUser(mutableUser)
}
}

has the following error

 [Static type checking] - Cannot find matching method com.atlassian.jira.user.util.UserUtil#getUserKeysForUser(com.atlassian.jira.user.ApplicationUser). Please check if the declared type is correct and if the method exists.

and I'm to stupid to solve this problem

1 answer

0 votes
Florian Bonniec
Community Champion
April 20, 2023

Hi @Frank Lohfeld 

 

Could you check group that grand application access instead ? If the user is not in any group that grant Software access it will be returned.

 

isUserInGroup(ApplicationUser user, String groupName)

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/security/groups/GroupManager.html

 

Regards

Suggest an answer

Log in or Sign up to answer