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

1 vote
Answer 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
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

1,208 views 2 13
Read article

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