Generate a list of space administrators and the space they administrate

Hi,

Would anybody know how I can get a list of space adminstrators and the space they administrate.

Does anybody know of a SQL query or macro plugin.

Why I need is this information so I can supply the helpdesk so they can supply the user who to contact concerning access to the required space.

So you have any ideas it would be great to hear from you. :-)

Many Thanks

Regards

Jaime

3 answers

1 accepted

You can add a user macro through Confluence Admin > User Macros and add the following template:

## This is an example macro
## @param Test:title=Test|type=string

#set($spaces = $spaceManager.getAllSpaces())

#foreach($space in $spaces) 
	<h3>Space Name: $space.getName()</h3>
	<table class="confluenceTable">
	
	#foreach ( $permission in $space.getPermissions() )
		#if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
			<tr>
			  <td class="confluenceTd">User</td>
			  <td class="confluenceTd">$permission.getUserName()</td>
			</tr>
		#elseif ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
			#set ( $group = $permission.getGroup() )
			<tr>
			  <td class="confluenceTd">Group</td>
			  <td class="confluenceTd">$group</td>
			</tr>
		#end
	#end
	
	</table>
#end

I know this is old, but i found a more streamlined approach to this which will only return the non-personal spaces and only list the administrators in a table.  Also the solution provided by the KB article causes massive performance issues even on small to medium sized confluence instances.  My solution runs in seconds compared to 30 minutes for the KB solution.

Here is my user macro:

## Macro title: Space Administrators
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Modified by: Adam Barylak
## Date created: 21/03/2012
## Date modified: 7/23/2017
## Installed by: <your name>
## Macro to display a list of space administrators
## @noparams
#set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
#set($spaces = $spaceManager.getAllSpaces())
<table class="aui aui-table-interactive">
<tr>
<th class="confluenceTh">Space</th><th class="confluenceTh">Administrator(s)</th>
</tr>
#foreach($spacer in $spaces)
#if (!$spacer.isPersonal())
<tr>
<td class="confluenceTd"><a href="$req.contextPath/display/$spacer.key">$spacer.name</a></td><td class="confluenceTd"><ul>
#set($administrators = $spaceManager.getSpaceAdmins($spacer))
#foreach($admin in $administrators)
<li>#usernameLink($admin.name)</li>
#end
</ul>
</td>
</tr>
#end
#end
</table>

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

377 views 20 10
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you