Forums

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

How to remove by script the permission from a space for a deleted user?

vandersluispe November 11, 2021

A user does not exist in Confluence anymore but still has some permissions on a Space and I need to remove those by a script.

A POST to 'https://<our instance>/rpc/json-rpc/confluenceservice-v2/removePermissionFromSpace' raises a com.atlassian.confluence.rpc.RemoteException: No user or group with the name "<userId>" exists.

The "Extender for Confluence" (https://it-lab-site.atlassian.net/wiki/spaces/RAEC/pages/559743018/REST+API+-+Space+Permissions) seems to be able to do the job but is not available on this instance.

Please advise.

1 answer

0 votes
Andrii Maliuta
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 11, 2021

Hello @vandersluispe ,

For Confluence Server it can be better to try to use the Groovy script runner like https://marketplace.atlassian.com/apps/1218812/power-groovy-for-confluence?hosting=server&tab=overview or a ScriptRunner (https://marketplace.atlassian.com/apps/1215215/scriptrunner-for-confluence?hosting=server&tab=overview) and use the Java API (https://docs.atlassian.com/ConfluenceServer/javadoc/7.14.0/) to get all required spaces and remove the necessary set of permissions for the space and specific user.

vandersluispe November 11, 2021

Hello @Andrii Maliuta ,

Thank you for your quick response. Unfortunately we are using Data Center (Groovy Script Runner is not yet available) and I am only Space Admin, no System Admin, so I can't (buy and) install plugins. Finally I can't even read Java and my Python script does much more than just remove some permissions on a space so a solution that can be built in, or invoked from, my script is preferred.

Andrii Maliuta
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 11, 2021

@vandersluispe got it, thanks for clarification :)

It seems like you can try to send POST request to <confluence-url>/spaces/doeditspacepermissions.action and set Headers and Form Data fields (corresponding to permissions checkboxes and user) to change the permissions via HTTP. I did not check it on practice yet, but may be worth trying.

E.g. POST /URL --data atl_token XXX confluence_checkbox_viewspace_user_TOKEN ...

vandersluispe November 11, 2021

@Andrii Maliuta  Wow! Bold! And quite a hassle. I briefly looked into it but that is not something I can build overnight. There is a lot of traffic going back and forth with cookies and all. Not my forte. I will certainly keep it in mind and if time allows do some trying. If everything else fails I can build in a chromedriver and use selenium to click on some buttons. In that case however, I cannot use the Token of the colleague using my script but will need his credentials for Confluence. Hmmm...

Thanks for setting me on a track to a solution! I remain open for suggestions.

Like Andrii Maliuta likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events