Generate a list of space administrators and the space they administrate

Jaime Romaguera October 10, 2012

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
Amalia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2012

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

1 vote
Adam Barylak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 26, 2017

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>
0 votes
Amalia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 10, 2012

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events