Forums

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

Confluence: How to remove space permissions of (inactive) users

Filip Labarque
Contributor
January 7, 2020

Hi,

 

I'm trying to create a script that will remove space permissions of inactive users.

This is what I got so far:

import com.atlassian.spring.container.ContainerManager;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.internal.security.SpacePermissionManagerInternal;
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.internal.security.SpacePermissionContext;

UserAccessor userAccessor = (UserAccessor) ContainerManager.getComponent("userAccessor");
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def spacePermissionManager = ComponentLocator.getComponent(SpacePermissionManagerInternal)

def user = userAccessor.getUserByName('<username>')
SpacePermissionContext context = SpacePermissionContext.builder().build()
spacePermissionManager.removeAllUserPermissions(user, context);

 

But the script does nothing at the moment. Does anyone know how to remove space permissions of a user?

 

best regards,

Filip

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Nic Brough -Adaptavist-
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 Champions.
August 11, 2022

So the quick answer is that Atlassian did not build Cloud in a way that enabled us to do all sorts of things we could do on server.  (That "we" is not just Adaptavist, it's all of us)

Behavriours and REST endpoints need a lot of support from Atlassian, and it's mostly not there.

That said, we (Adaptavist) have been working with Atlassian to move to being able to support stuff like this, and in May, we were able to release a Beta for Behaviours - see https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Behaviours-for-Jira-Cloud/ba-p/2034151

REST endpoints are also on the list...

shrikant maheshwari
August 15, 2022

@Nic Brough -Adaptavist- 

Hey Nic,

I also came to know from some of the folks from Atlassian about this but could you let me know when would REST end points feature be available in Script runner cloud ?

Also could you let me know if there are any other plugins or workaround available for having REST end points working in JIRA cloud ?

Nic Brough -Adaptavist-
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 Champions.
August 15, 2022

I  don't have a timeline for this yet.

There's no other app that does it because Atlassian doesn't yet support apps that can.  And there's nothing to "work around", it's a function that simply is not there.

shrikant maheshwari
August 16, 2022

thank you Nic

shrikant maheshwari
August 17, 2022

Hi Nic,

Could you please share me the link from where i can download the Beta version of Script runner for JIRA Cloud.

I have currently installed the script runner on jira cloud but it does not have Behaviour feature ?

TAGS
AUG Leaders

Atlassian Community Events