Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Remove user permissions from Confluence space

Hello,

 

Could someone help me with ScriptRunner REST endpoint running on Confluence Server 7.2.0?

 

I just need to remove user permissions from space only. For example, I pass username and space key, and the script removes all permissions. I've been trying to use SpaceManager, SpaceManagerInternal but my context is always null. 

 

def space = spaceManager.getSpace(spaceKey)

SpacePermissionContext context = SpacePermissionContext.builder().build()

spacePermissionManager.removeAllUserPermissions(user,context)

 

The builder().build() doesn't work, and createDefault() as well.

How do I use this context in the right way?

 

Thanks.

1 answer

Hi Tomislav! 

I was able to get this working with the snippet below: 

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.internal.security.SpacePermissionContext
import com.atlassian.confluence.security.SpacePermissionManager
import com.atlassian.confluence.user.UserAccessor


def spacePermissionManager = ComponentLocator.getComponent(SpacePermissionManager)
SpacePermissionContext context = SpacePermissionContext.createDefault()

def userAccessor = ComponentLocator.getComponent(UserAccessor)
def user = userAccessor.getUserByName("<username>")

spacePermissionManager.removeAllUserPermissions(user, context)

For reference, I am using Confluence 7.8 with ScriptRunner 6.14.0 installed. 

Please let me know if this works for you! 

Thanks,
Lee

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

184 views 2 9
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