Managing users and roles

Andrey Butuzov August 19, 2021

Good day. 

We audit roles and permissions in all Jira projects. Users, who have project admin add other employees to project roles locally. 

Every project has AD group and we want that all users request this groups from company portal. We want to get away from local rights. 

So, we have many projects with users, who added locally by project admin. 

For example: 

jira.jpg

g_jira_123 - AD group;

Valeriya - employee, who was added by project admin. 

 

Is there any way to remove all this users from all projects? 

 

Jira Server 8.5.3

 

2 answers

1 accepted

0 votes
Answer accepted
Ravi Sagar _Sparxsys_
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.
August 19, 2021

Hi @Andrey Butuzov 

Do you have ScriptRunner for Jira on your server instance? If yes then doing this is quite straight forward using ProjectRoleService.


ProjectRoleService projectRoleService = ComponentAccessor.getComponent(ProjectRoleService)
projectRoleService.removeActorsFromProjectRole(..)

This post has a good example.

Ravi

Andrey Butuzov August 20, 2021

Hi @Ravi Sagar _Sparxsys_ 

Thanks for your reply and tutorials from YouTube :) 

Yes, we have ScriptRunner. 

Will try to study. 

I'm beginner in ScriptRunner. Can you suggest where I should to place this code? 

Screenshot 2021-08-20 at 11.02.33.png

I know that my question is very simple, sorry for that :) 

Like Ravi Sagar _Sparxsys_ likes this
Ravi Sagar _Sparxsys_
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.
August 20, 2021

Thanks. You can run ad-hoc code from the Console.

Like Andrey Butuzov likes this
Andrey Butuzov August 20, 2021

Thanks a lot!

0 votes
Radek Dostál
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.
August 19, 2021

You could do some data mining with REST https://docs.atlassian.com/software/jira/docs/api/REST/8.18.2/#project/{projectIdOrKey}/role

 

Each "project role member", aka "actor" has a type property, whether it's a user or a group, so for example:

// https://jiraurl.com/rest/api/2/project/13004/role/10002

{
"self": "https://jiraurl.com/rest/api/2/project/13004/role/10002",
"name": "Administrators",
"id": 10002,
"description": "A project role that represents administrators in a project",
"actors": [
{
"id": 146569,
"displayName": "jira-administrators",
"type": "atlassian-group-role-actor",
"name": "jira-administrators",
"avatarUrl": "https://jiraurl.com/secure/useravatar?size=xsmall&avatarId=10123"
},
{
"id": 238429,
"displayName": "Radek Dostal",
"type": "atlassian-user-role-actor",
"name": "supersecretname",
"avatarUrl": "https://jiraurl.com/secure/useravatar?size=xsmall&avatarId=14725"
}
]
}

 

The types are either 'atlassian-group-role-actor' or 'atlassian-user-role-actor'. So doing some data mining you would get something akin to project:role:user list(s) and then you could delete those actors with REST again https://docs.atlassian.com/software/jira/docs/api/REST/8.18.2/#project/{projectIdOrKey}/role-deleteActor

 

You could do the same thing with java/groovy if you have a plugin allowing you to run groovy scripts, but it's essentially the same thing as with REST, get role actors, identify which ones are users, delete.

 

Other than that there is no way to do any such a purge like this in bulk through Web UI. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events