Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello,
being new to Confluence Administration, could somebody please give me the code for a new User Macro that lists the usernames of alle Space administrators.
I already know about this link but don't know how to integrate the sql-query into the code part of the macro
Thx,
Michael
https://confluence.atlassian.com/confkb/how-do-i-view-a-list-of-all-space-administrators-for-all-spaces-346325879.htmlhttps://confluence.atlassian.com/confkb/how-do-i-view-a-list-of-all-space-administrators-for-all-spaces-346325879.html
The SQL query does not need to be integrated into the code for the user macro. They are just showing you two ways to get the data. You can use either the SQL query or the user macro. The user macro should work as is.
If you have a lot of users it can take a LONG time to render the page as is checks for each user against each space if that user can administer the space. In fact it may take so long that it times out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In Confluence 6.8.2, the Macro code provided at this link resulted in a couple issues that caused me to write it in a slightly different way. It is much more performant in my case.
I believe the biggest performance issue for me was by calling:
For Confluence 6.8.2, I changed it to:
And, I swapped the loops, and made sure to only have one row printed per space so that the 'Space Admin' table cell contains a comma-delimited list of space admins for each space.
My resulting code is:
## Macro title: getSpacesAndAdmins
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Darin
## Date created: dd/mm/yyyy
## Installed by: Darin
## @noparams
#set($D = "$")
#set($P = "#")
#set($users = $userAccessor.getUsers())
#set($spaces = $spaceManager.getAllSpaces())
<div id="conf-space-lister"><ul><span id="conf-space-loading" class="aui-icon aui-icon-wait">Loading...</span></ul></div>
<div id="conf-spacetbl-lister">
<table class="confluenceTable tablesorter tablesorter-default stickyTableHeaders" role="grid" resolved="" style="padding: 0px;"><colgroup><col><col><col><col></colgroup>
</table>
</div>
<pre><script>
AJS.${D}('${P}conf-space-loading').remove()
AJS.${D}('${P}conf-spacetbl-lister table').append('<tr><td colspan="4"><p><b>Found ' + $spaces.size() + ' Spaces</b><br><br></p></td></tr>');
AJS.${D}('${P}conf-spacetbl-lister table').append('<tr role="row" class="tablesorter-headerRow"><th class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="0" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" aria-sort="none" aria-label="Id: No sort applied, activate to apply an ascending sort" style="user-select: none; min-width: 8px; max-width: none;"><div class="tablesorter-header-inner">Space Id</div></th><th class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="1" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort" style="user-select: none; min-width: 8px; max-width: none;"><div class="tablesorter-header-inner">Space Name</div></th><th class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="2" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" aria-sort="none" aria-label="Value: No sort applied, activate to apply an ascending sort" style="user-select: none; min-width: 8px; max-width: none;"><div class="tablesorter-header-inner">Space Key</div></th><th class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="3" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" aria-sort="none" aria-label="Value: No sort applied, activate to apply an ascending sort" style="user-select: none; min-width: 8px; max-width: none;"><div class="tablesorter-header-inner">Space Admins</div></th></tr>');
#foreach($spacer in $spaces)
AJS.${D}('${P}conf-spacetbl-lister table').append('<tr><td class="confluenceTd">$spacer.id</td><td class="confluenceTd">$spacer.name</td><td class="confluenceTd">$spacer.key</td><td class="confluenceTd">#set($admins=$spaceManager.getSpaceAdmins($spacer)) #foreach($admin in $admins) $admin.name, #end</td></tr>');
#end
AJS.${D}('${P}conf-spacetbl-lister table').append('</tbody></table>');
</script></pre>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Changed the foreach to add a hyperlink to the space listing:
#foreach($spacer in $spaces)
AJS.${D}('${P}conf-spacetbl-lister table').append('<tr><td class="confluenceTd">$spacer.id</td><td class="confluenceTd"><a href="$spacer.getUrlPath()">$spacer.name</a></td><td class="confluenceTd">$spacer.key</td><td class="confluenceTd">#set($admins=$spaceManager.getSpaceAdmins($spacer)) #foreach($admin in $admins) $admin.name, #end</td></tr>');
#end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Darin!
I am wondering if there is a way to get this for all spaces EXCEPT the ones that are set to "Archive" state.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Darin Hafer !
Thanks for that macro...the original macro keeps crashing here, but yours is working great!
Is it possible to list all spaces except the personal spaces (starting with "~")?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My macro does not look at the 'confluence-administrators' group.
I loops through all Spaces, and return the users who are permitted to Administer a Space.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Yes I figured out that much and I already thought there is no easy way integrating it.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Michael,
Do you only have one space? If so, go to Space Tools --> Permissions --> And at the far right, check which user(s) have Admin marked in Green.
Victor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Michael,
Create a group, Confluence-Administrator, in the global permission, give the group, Confluence Administrator permission, add those that you want as admins to it. Then in each space, give the group Space Admin Permissions.
Victor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.