Is there a way to find the list of all the users who have access to a particular project

Hi

Could someone help me with a way / script / query wherein I can extract the list of all the users who have access to a particular Jira project. The project is currently using both Users and Groups in the Roles and Permissions

Regards,

Sateesh

6 answers

1 accepted

Hi Sateesh

try this query in Database, projectroleactor will give you the list of users who have access on a particular project.

SELECT * FROM `projectroleactor`

where pid = 'XXX'

and projectroleid = 'yyy';

u can get the pid (project id) from the below table.

SELECT * FROM `project`;

projectroleid u can get from

select * from projectrole;

Regards

Sakthi

0 votes

First, you need to define what you mean by "access" to the project. The right to see issues in it? Be in one or more specific roles?

Here is the groovy script to which shows all the users under Administrator role. Add code for required roles:

ProjectRoleService projectRoleService = (ProjectRoleService) ComponentAccessor.getComponentOfType(ProjectRoleService.class);
ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
ProjectManager projectManager = ComponentAccessor.getProjectManager();

Project project = projectManager.getProjectObjByKey('<PROJECT KEY>')
ProjectRole administrator = projectRoleManager.getProjectRole("Administrators");

ErrorCollection ec = new SimpleErrorCollection();
ProjectRoleActors existingActors = projectRoleService.getProjectRoleActors(administrator,project,ec);
if (existingActors != null){
   Set<User> users = existingActors.getUsers();
   // Do your thing
}

return

Here is the error I get.

javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: unable to resolve class ProjectRoleService 
 @ line 1, column 20.
   ProjectRoleService projectRoleService = (ProjectRoleService) ComponentAccessor.getComponentOfType(ProjectRoleService.class);
                      ^

Script3.groovy: 1: unable to resolve class ProjectRoleService 
 @ line 1, column 41.
   eService projectRoleService = (ProjectRo
                                 ^

Script3.groovy: 2: unable to resolve class ProjectRoleManager 
 @ line 2, column 20.
   ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
                      ^

Script3.groovy: 2: unable to resolve class ProjectRoleManager 
 @ line 2, column 41.
   eManager projectRoleManager = (ProjectRo
                                 ^

Script3.groovy: 3: unable to resolve class ProjectManager 
 @ line 3, column 16.
   ProjectManager projectManager = ComponentAccessor.getProjectManager();
                  ^

Script3.groovy: 5: unable to resolve class Project 
 @ line 5, column 9.
   Project project = projectManager.getProjectObjByKey('ASC')
           ^

Script3.groovy: 6: unable to resolve class ProjectRole 
 @ line 6, column 13.
   ProjectRole administrator = projectRoleManager.getProjectRole("Users");
               ^

Script3.groovy: 8: unable to resolve class ErrorCollection 
 @ line 8, column 17.
   ErrorCollection ec = new SimpleErrorCollection();
                   ^

Script3.groovy: 8: unable to resolve class SimpleErrorCollection 
 @ line 8, column 22.
   ErrorCollection ec = new SimpleErrorCollection();
                        ^

Script3.groovy: 9: unable to resolve class ProjectRoleActors 
 @ line 9, column 19.
   ProjectRoleActors existingActors = projectRoleService.getProjectRoleActors(administrator,project,ec);
                     ^

Script3.groovy: 11: unable to resolve class User 
 @ line 11, column 8.
      Set<User> users = existingActors.getUsers();
          ^

You need to include the required imports. Please read up on groovy scripting. Use these imports:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.projectroles.ProjectRoleService;
import com.atlassian.jira.security.roles.ProjectRoleManager;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleActors;
import com.atlassian.jira.util.ErrorCollection;
import com.atlassian.jira.util.SimpleErrorCollection;

Open permission scheme used for a project. Check to which(Users / Groups / Project Roles) have you provided "Browse Projects" permission.

Count them together.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,095 views 13 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot