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

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

How to extract groups and users with space permissions using scriptrunner

I have already got the users and groups list with space permissions but I would like to get the permission which they have also like given below:

viewspace:
 users:
   user1
   user2
groups:
 confluence-users
 confluence-administrators

import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.spaces.SpaceType
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.security.SpacePermissionManager
import com.atlassian.confluence.user.UserAccessor
import com.atlassian.user.GroupManager
import org.apache.log4j.Level
import org.apache.log4j.Logger
import groovy.transform.Field


@Field final Logger logger = Logger.getLogger("in.aditya.sr4j")
logger.setLevel(Level.DEBUG)


def spaceManager = ComponentLocator.getComponent(SpaceManager)
def spacePermissionManager = ComponentLocator.getComponent(SpacePermissionManager)
def groupManager = ComponentLocator.getComponent(GroupManager)
def userAccessor = ComponentLocator.getComponent(UserAccessor)
def space = spaceManager.getSpace('testspace')
def usersWithSpacePermissions = spacePermissionManager.getUsersWithPermissions(space).name.toList().unique()
def groupsWithSpacePermissions = spacePermissionManager.getGroupsWithPermissions(space).toList().unique()

 

0 answers

Suggest an answer

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

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

158 views 5 8
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