Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

Hi Filip!

The SpacePermissionManager removeAllUserPermissions() method is used to remove individual space permissions from the specified user.

This means that if a user is a space administrator of 'Space A' then removeAllUserPermissions('example_user') would remove their individual administrator permissions for any space within your instance, but it would not remove any permissions that receive from a Confluence group they belong to. 

To do this you will need to remove the inactive user from any Confluence groups they belong to. We have an example script that displays how you can remove specified users from a group here.

Kind regards, 
Lee

Removing individual space permissions not given by groups would still be nice to know how. Since these are easily forgotten, and sometimes added ad hoc.

Essentially for longer instances of confluence many "individual" rights till exist on spaces even after they have lone gone from the company.

Also would be useful for any IDM project.

Hi Mauri! 

You can remove a user's permissions on a single space with the snippet linked here.

If you want to remove every space permission a user has then you can use the snippet here

I hope this helps but let me know if you have any other questions! 

Kind regards, 
Lee

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

76 views 0 4
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you