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

Know space administrators

Arantxa Lacasa Madero March 20, 2012

Hello,

Is there a way to know the spaces administrators from Confluence?

Any time a user needs some permissions (read, write, etc.) of an space, we need to see who are the administrators of that space and then tell the user to ask any of them to give them the permissions.

Spaces administrators manage their groups and their users.

Is there any way that users can know the spaces administrators without asking confluence administrators?

9 answers

1 accepted

4 votes
Answer accepted
Andrew Frayling
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.
April 27, 2012

Finally got around to figuring out a different way of doing this, try the following instead:

## Macro title: Space Administrators
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 28/04/2012
## Installed by: <your name>

## Macro to list all users and groups with the permission to administer the current space.
## @noparams

<h1>Space Adminstrators</h1>
 
<p>The following users and groups have permission to administer the <strong>$space.getName()</strong> Space.</p>

<h2>Users</h2>
<table class="confluenceTable">
  <tr>
    <th class="confluenceTh">Space Administrators</th>
  </tr>
  #foreach ($permission in $space.getPermissions())
    #if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
      <tr>
        <td class="confluenceTd">#usernameLink($permission.getUserName())</td>
      </tr>
  #end
#end
</table>

<h2>Groups</h2>
#foreach ($permission in $space.getPermissions())
  #if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
    #set ( $groupString = $permission.getGroup() )
    #set ( $groupObject = $userAccessor.getGroup($groupString) )
    #set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
    
    <h3>$groupString</h3>
    <table class="confluenceTable">
      <tr>
        <th class="confluenceTh">Space Administrators</th>
      </tr>
      

      #foreach ($member in $memberList)
        <tr>
          <td class="confluenceTd">#usernameLink($member)</td>
        </tr>
      #end
    </table>
  #end
#end

It looks at the permissions on a space and lists the users, groups and members of those groups rather than looking at all the users and then figuring out which groups they can administer.

Andrew.

5 votes
Aaron J_ Schmidt September 26, 2012

I wanted a version of this that would report on all global (non-personal) spaces, and would ouptut everything in one table. Here's what I came up with.

## Macro title: Space Administrators
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Aaron Schmidt
## Date created: 09/27/2012
## Macro to list all users and groups with the permission to administer specified spaces.
## @noparams

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

<h1>Space Adminstrators</h1>

<table class="confluenceTable">
  <tr>
    <th class="confluenceTh">Space</th>
	<th class="confluenceTh">Key</th>
	<th class="confluenceTh">Users</th>
	<th class="confluenceTh">Groups</th>
  </tr>

#foreach ( $space in $spaces )
  #if ($space.isGlobal())
  <tr>
	#set($result=$space.getDescription().getDescriptionTitle())

	<td class="confluenceTd"><a href="$req.contextPath$space.getUrlPath()">$space.getName()</a></td>
	<td class="confluenceTd"><a href="$req.contextPath$space.getUrlPath()">$space.getKey()</a></td>
	<td class="confluenceTd">
    #foreach ($permission in $space.getPermissions())
      #if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
        #usernameLink($permission.getUserName())<br>
	  #end
	#end
    </td>
	<td class="confluenceTd">
    #foreach ($permission in $space.getPermissions())
      #if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
		#set ( $groupString = $permission.getGroup() )
		#set ( $groupObject = $userAccessor.getGroup($groupString) )
		#set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
		<strong>$groupString</strong><br>
		#foreach ($member in $memberList)
		  #usernameLink($member)<br>
		#end
 	  #end
	#end
    </td>
  </tr>
  #end
#end
</table>

James Roberts May 7, 2013

This is exactly what I need but we have too many spaces in our system and the macro continues to timeout. Is there any way that I could specify the spaces that I need and hard code them into the macro itself?

Bruce von Kugelgen November 17, 2015

Fantastic! Exactly what I needed.

Lars Swart
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.
January 15, 2017

Hi, I added a code line that shows the Space Logo.

But it only shows the icons for the spaces the user has access too. The space names and links are fine. 

<td class="confluenceTd"><img class="space logo" width="32" height="32"
src="$spaceManager.getLogoForSpace($space.key).getDownloadPath()" alt="$space.key"/> <a  href="$req.contextPath$space.getUrlPath()">$space.getName()</a></td>

I also tried "$spaceManager.getLogoForGlobalcontext().getDownloadPath()" instead. But that change crashed the whole macro. 

Do you have any further ideas how I every user is able to see the space logos?

 

Here is the description for the spacemanager

Here the detail for the get Space Logo Class

 

And finally the whole script.

## Makro Titel: Bereich und Admins
## Kein Makrohauptteil
##
## Zeigt alle Bereiche und die Administratoren
## @noparams
 
#set ( $spaces = $spaceManager.getAllSpaces() )
 
<table class="confluenceTable">
  <tr>
    <th class="confluenceTh">Bereich</th>
    <th class="confluenceTh">Bereichsschlüssel</th>
    <th class="confluenceTh">Nutzer mit Adminrecht</th>
    <th class="confluenceTh">Gruppen mit Adminrecht</th>
  </tr>
 
#foreach ( $space in $spaces )
  #if ($space.isGlobal())
  <tr>
    #set($result=$space.getDescription().getDescriptionTitle())
 
    <td class="confluenceTd"><img class="space logo" width="32" height="32"
src="$spaceManager.getLogoForSpace($space.key).getDownloadPath()" alt="$space.key"/> <a  href="$req.contextPath$space.getUrlPath()">$space.getName()</a></td>
    <td class="confluenceTd"><a href="$req.contextPath$space.getUrlPath()">$space.getKey()</a></td>
    <td class="confluenceTd">
    #foreach ($permission in $space.getPermissions())
      #if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
        #usernameLink($permission.getUserName())<br>
      #end
    #end
    </td>
    <td class="confluenceTd">
    #foreach ($permission in $space.getPermissions())
      #if ($permission.isGroupPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
        #set ( $groupString = $permission.getGroup() )
        #set ( $groupObject = $userAccessor.getGroup($groupString) )
        #set ( $memberList = $userAccessor.getMemberNamesAsList($groupObject) )
        <strong>$groupString</strong><br>
        #foreach ($member in $memberList)
          #usernameLink($member)<br>
        #end
      #end
    #end
    </td>
  </tr>
  #end
#end
</table>
2 votes
Jeff Louwerse
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.
April 28, 2017

I know this is a very old post but I tried most of these and they were very inefficient if you have a large user base..  There is no need to loop though 6000 users to find the 2 with permissiosns!  or maybe this isn't the post I was reading earlier today..  Maybe someone else added this already but the import from Atlassin Answers is too crappy to try and read.   so anyway   

These are working for me on 6.1.2.  This picks up users & groups and ommits (I think) system admins.

To list all spaces and their admins (could be a security issue if made public)

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

<table class="confluenceTable"> 
#foreach($thisSpace in $spaces )
  #if ($thisSpace.isGlobal() )
    <tr>
       <td class="confluenceTd">
            <img class="space logo" width="32" height="32" src="$spaceManager.getLogoForSpace($thisSpace.key).getDownloadPath()" alt="$thisSpace.key"/>
            $thisSpace.getName()
       </td>
       <td class="confluenceTd">
           #set($spaceAdmins = $spaceManager.getSpaceAdmins($thisSpace  ))
           #foreach($spaceAdmin in $spaceAdmins )
              #usernameLink($spaceAdmin.name)<BR>
           #end
        </td>
    </tr>
   #end
#end
</table>

When in a space, a list for that space. (wasn't part of the question but here it is).. I use this on each space to point users to when they request permissions from the system admin. 

#set($spaceAdmins = $spaceManager.getSpaceAdmins($space))
<table class="confluenceTable">
   <tr><th class="confluenceTh">Space Administrators</th></tr>
   #foreach($spaceAdmin in $spaceAdmins )
   <tr><td class="confluenceTd">#usernameLink($spaceAdmin.name)</td></tr>
   #end
</table>
2 votes
Andrew Frayling
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.
March 20, 2012

Hi,

Try this 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
## Date created: 21/03/2012
## Installed by: &lt;your name&gt;
## Macro to display a list of user that are able to administer the current space.
## @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($loginManager = $containerContext.getComponent('loginManager'))
#set($users = $userAccessor.getUsers())

&lt;table class="confluenceTable"&gt;
  &lt;tr&gt;
    &lt;th class="confluenceTh"&gt;Space Administrators&lt;/th&gt;
  &lt;/tr&gt;

#foreach($user in $users)
  ## list the users who can administer the current space
  #if ($permissionHelper.canAdminister($user, $space))
    &lt;tr&gt;
      &lt;td class="confluenceTd"&gt;#usernameLink($user.name)&lt;/td&gt;
    &lt;/tr&gt;
  #end
#end
&lt;/table&gt;

Tested on Confluence 4.1.5. It gives you a list of users who can administer a space with the profile pop-up hover so users can see their profile / contact details.

Hope that helps?

Andrew.

Andrew Frayling
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.
March 20, 2012

Just did another quick test and my macro does pick up space administrators that have picked up those permissions via a group or by being a Confluence Administrator and not just the named individual users that have been given space administrator permissions.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 21, 2012

Excellent! Thanks Andrew.

Andrew Frayling
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.
March 26, 2012

Hi Aranxta,

Did my macro work for you? If so could you mark my answer as correct please?

Thanks,

Andrew.

Arantxa Lacasa Madero March 26, 2012

Hi Andrew,

It is not working for me.

Could you tell me which option should I choose in "Macro Body Processing" and "<label for="">Output Format</label>"?

Thanks for your help!

Andrew Frayling
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.
March 26, 2012

Hi Arantxa,

Macro Body Processing should be set to "No Macro Body" so there is no "Output Format". Usage in the editor should just be {spaceadmins} (or whatever you decide to use as the Macro Name. Have a look at https://skitch.com/sphericaln/8pchi/edit-user-macro-confluence for a screenshot of how I've got it set up on my system.

Hope that helps,

Andrew.

Arantxa Lacasa Madero March 26, 2012

Hi Andrew,

It may not be working for me because we are using Confluence 3.5.7, don't you think?

Andrew Frayling
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.
March 26, 2012

Hi Arantxa,

I just tried on 3.5.7 and it works, Output Format set to HTML, but all other options the same as the screenshot I previously posted.

What behaviour are you seeing? It's listing everyone? It's listing no-one? It's throwing an error?

Andrew.

Arantxa Lacasa Madero March 26, 2012

Hi Andrew,

These are the steps I made:

1. Create an user macro with name spaceadmins (Macro Body Processing: No Macro Body / Output Format: HTML).

2. Copy your macro and save.

3. Create a new page in Confluence.

4. Edit the page and add only the text: {spaceadmins} (when I selected the macro, this text was added).

5. When I access to the page, it keeps thinking for a while, and then it says:

The page you are trying to access does not exist on the server

Andrew Frayling
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.
March 26, 2012

Could you try a couple of things:

  • A different title for the page
  • A page with the same title as you've been using, but without the macro on it
  • A different name for the macro
  • Making sure there are no page level restrictions on the page, or any pages above it in the hiearchy

The only time I've seen errors similar to that are when there have been special characters in the title or the macro, or if there are page level restrictions being applied.

Thanks,

Andrew.

Andrew Frayling
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.
March 28, 2012

Hi Arantxa,

Did you get any further with this?

Had another thought, didn't you have other problems with your wiki caused by a custom theme? That's not what's happening here is it? If you're seeing the "page does not exist" error in a Space that's using the custom theme could you try in a Space that's using one of the default themes?

Also, do other other macros work? Could you try creating a new one and just use the default macro template to see if it's a problem with this macro or user macros in general?

Andrew.

Arantxa Lacasa Madero April 2, 2012

Hello Andrew,

I did everything you suggested but it keeps thinking and then it throws the error.

I've seen your macro and it loops through all users in Confluence and then, if the user has administrator permissions on that space, it prints it.

The problem is that we have a lot of users, too many. So I can not do this loop.

I would need to do it in the other way: Having the name of the spaces, get the users that have that permission.

I don't know if that is possible...

I appreciate your help.

Andrew Frayling
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.
April 2, 2012

Hi Arantxa,

I'll have a look, but I'm not sure if it can be done the other way around. I know that you can query a Space to find out who created it, but I'm not aware of a method on the Space object that will list users or administrators of a Space.

If I find anything I'll post back here.

Andrew.

Arantxa Lacasa Madero May 10, 2012

Andrew, I have just seen your macro, it is great!! Thank you so muuuuuuuch!! :)

Andrew Frayling
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.
May 10, 2012

You're welcome. I've converted the new macro to be an answer rather than a comment, if the macro works for you could you mark it as correct so other people reading this thread know which one worked for you?

Thanks,

Andrew.

Deleted user June 26, 2012

Hi Andrew

I've tested your 2nd macro in Confluence 3.5.16.

Andrew said: "Just did another quick test and my macro does pick up space administrators that have picked up those permissions via a group or by being a Confluence Administrator and not just the named individual users that have been given space administrator permissions."

That's right. It shows all members of the group confluence-administrators (in a random order) which isn't really what's needed. If it could be tweaked so the local space admin was either at the top or the bottom, I could add words to say something like "contact the person at the top of the list first".

Edited version: But don't spend any time on it on my account ... I remembered that I actually already have a working version of a macro like this [I won't name names, he knows who he is ;) ] The alternative version displays the results like this:

Administrators for Space X (SPACEX)
User: Elmer Fudd
User: Barney Rubble
System Admin: Foghorn Leghorn

... which makes it clearer who is a local admin vs who isn't.

Deleted user June 27, 2012

... and yet another reason why I hate wysiwyg editors. The "code" snippet I pasted above looked fine until I edited the comment. <grumble/>

Andrew Frayling
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.
June 27, 2012

Hi Kathleen,

I think the revised macro that I already posted on this thread (the one that ended up being marked correct) does what you want? It displays the users that have explicitly been given the admin permission first and then displays the users that have inherited the permission through group membership.

Was that what you were looking for?

Cheers,

Andrew.

0 votes
James Beagrie June 22, 2022

Appreciate this is an old topic but I'm looking to use the following first snippet. This brings out all spaces globally except personals which is ideal.

However, I only want it to include the individually named users with space admin. Similar to the second snippet. I've tried to have a play but it doesn't seem to be my game. Does anyone have any ideas? Maybe someone has a new iteration of these macros to share?

First snippet:

## Macro title: Space Administrators
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 28/04/2012
## Installed by: <your name>

## Macro to list all users and groups with the permission to administer the current space.
## @noparams

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

<table class="confluenceTable">
#foreach($thisSpace in $spaces )
#if ($thisSpace.isGlobal() )
<tr>
<td class="confluenceTd">
<img class="space logo" width="32" height="32" src="$spaceManager.getLogoForSpace($thisSpace.key).getDownloadPath()" alt="$thisSpace.key"/>
$thisSpace.getName()
</td>
<td class="confluenceTd">
#set($spaceAdmins = $spaceManager.getSpaceAdmins($thisSpace ))
#foreach($spaceAdmin in $spaceAdmins )
#usernameLink($spaceAdmin.name)<BR>
#end
</td>
</tr>
#end
#end
</table>
#foreach ($member in $memberList)
<tr>
<td class="confluenceTd">#usernameLink($member)</td>
</tr>
#end

Second snippet:

## Macro title: Space Administrators
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 28/04/2012
## Installed by: <your name>

## Macro to list all users and groups with the permission to administer the current space.
## @noparams

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

<h1>Space Adminstrators</h1>

<p>The following users and groups have permission to administer the <strong>$space.getName()</strong> Space.</p>

<h2>Users</h2>
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Space Administrators</th>
</tr>
#foreach ($permission in $space.getPermissions())
#if ($permission.isUserPermission() && $permission.getType() == "SETSPACEPERMISSIONS")
<tr>
<td class="confluenceTd">#usernameLink($permission.getUserName())</td>
</tr>
#end
#end
</table>
#foreach ($member in $memberList)
<tr>
<td class="confluenceTd">#usernameLink($member)</td>
</tr>
#end

Thanks

0 votes
Tiago Cardoso April 9, 2019

<removed by author>

0 votes
Abhijit Das August 29, 2018

@Jeff Louwerse I have a use-case here. Is it possible to use your 2nd snippet, to find the list of admins for a given space? Basically, this snippet lists the admins of the space in a page, but the page needs to exist under that space.

I need to have a page that is globally available, and then the user can enter the space name or space key and that should list out all the admin users.

Your first snippet works, but we have too large a user database and space database for the page to get rendered (Hence it is failing). 

 

@Andrew Frayling - I tried your macro (as posted in answer) on 6.6.3 but it gives me the error "Page cannot be rendered" 

Jeff Louwerse
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.
September 6, 2018

I am just spitballing here .. if you wanted to use sniplet#2, you would need to change line 1 from

#set($spaceAdmins = $spaceManager.getSpaceAdmins($space))

 to something like this

#set($thisSpace   = $spaceManager.getSpace(<your space key here>))
#set($spaceAdmins = $spaceManager.getSpaceAdmins($thisSpace)
)

 

0 votes
Sergey Svishchev
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.
May 20, 2014

Since 5.2, this is available in the app itself:

In the Spaces Directory, choose the new Space Details icon , or go to 'Space Tools' > 'Overview' within a space to view a list of all the users who have 'Space Admin' permissions for that space.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 20, 2012

Not natively, but I've seen it done with the reporting plugin, and I wrote a really simple plugin that does it as a macro (for 3.4, but probably works in most other versions), so you'll need to do some digging/coding. (From memory, the plugin I did was very simple to write)

Arantxa Lacasa Madero March 20, 2012

Thank you Nic.

Is the plugin you did available for me? I'd appreciate if I could provide it.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 20, 2012

No, it belongs to a client, so I can't distribute it without checking. (I think they'll be fine, but I also need to make time to get into the plugin exchange stuff properly. And it's for 3.4, not sure it'll work on 4.x)

Andrew's macro will do it, although I'm not sure it'll pick up groups or system-admins.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events