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

Sateesh Chandra March 31, 2014

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

0 votes
Answer accepted
Sakthi Balaji March 31, 2014

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
Andris Grinbergs
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.
March 31, 2014

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

Count them together.

0 votes
Sateesh Chandra March 31, 2014

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();
          ^
Shravan P March 31, 2014

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;

0 votes
Shravan P March 31, 2014

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('&lt;PROJECT KEY&gt;')
ProjectRole administrator = projectRoleManager.getProjectRole("Administrators");

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

return

0 votes
Nadir MEZIANI
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.
March 31, 2014

Hi,

Look this link, it can give you what do you need.

https://answers.atlassian.com/questions/163400/does-jira-log-admin-s-changes

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 31, 2014

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?

Suggest an answer

Log in or Sign up to answer