It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Display all the groups, users of each space

Rumceisz May 13, 2012

Hi All,

as a Confluence admin I need to achieve an overview. Hence, we have already more than 140 different spaces and 3 times more groups, it's very cumbersome to overview the space permissions, groups and users.

I'd liket to implement a macro which display the groups, permissions and users of each spaces, this way:

SpaceA

group1

permission(s) of the group in this space: e.g. VIEWONLY, ADMIN, etc.

user list of this group

group2

permission(s) of the group in this space: e.g. VIEWONLY, ADMIN, etc.

user list of this group

.....

SpaceB

groupX

permission(s) of the group in this space: e.g. VIEWONLY, ADMIN, etc.

user list of this group

.....

So, this macro would be on a page especially serves the admins to have an overview.

I got several macro code yet, which are give solutions for these features but apart:

This macro displays the groups and the group's user list of a space:

#foreach ($permission in $space.getPermissions())
  #if ($permission.isGroupPermission() && $permission.getType() == "VIEWSPACE")
    #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
#foreach ($permission in $space.getPermissions())
  #if ($permission.isGroupPermission() && $permission.getType() == "COMMENT")
    #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
#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

This macro list the groups with all the spaces having access to:

<h1>Groups</h1>
 
## get all the groups
#set ( $allGroups = $userAccessor.getGroupsAsList() )
 
## get all the spaces
#set ( $allSpaces = $spaceManager.getAllSpaces() )
 
#foreach ($group in $allGroups)
  <h2>$group</h2>
  #foreach ($space in $allSpaces)
    <h3>$space.getName()</h3>
    #foreach ($permission in $space.getPermissions())
      #if ($permission.isGroupPermission())
        #if ($permission.getGroup() == $group)
          $permission.getType()<br />
        #end
      #end
    #end
  #end
#end

This macro list the permissions of a group on a particular space:

## Macro title: Group Permissions
## Macro has a body: Y or N (N)
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 06/05/2012
## Installed by: <your name>
 
## Macro loops through every group and every space listings permissions on that space grouped by group
## @noparams
 
<h1>Groups</h1>
 
## get all the groups
#set ( $allGroups = $userAccessor.getGroupsAsList() )
 
## get all the spaces
#set ( $allSpaces = $spaceManager.getAllSpaces() )
 
#foreach ($group in $allGroups)
  <h2>$group</h2>
  #foreach ($space in $allSpaces)
    <h3>$space.getName()</h3>
    #foreach ($permission in $space.getPermissions())
      #if ($permission.isGroupPermission())
        #if ($permission.getGroup() == $group)
          $permission.getType()<br />
        #end
      #end
    #end
  #end
#end

(Thanks to Andrew!)

So the features are apart but how can they achieve my requrement?

Can you please suggest?

Thanks in advance!

Rumi

3 answers

1 accepted

2 votes
Answer accepted

This is what we use:

{cache:refresh=7d|showRefresh=true|showDate=true}
{cli:profile=confluence|hideOutput=true|subdirectory=.} 
-a getSpacePermissionList --file spacePermissions.csv 
{cli} 

{csv:script=#cli/spacePermissions.csv|autoNumber=true}
{csv}
{cache}

This uses Confluence CLI Plugin (needs 2.6.0 or higher), Confluence Cache Plugin, Confluence Table Plugin

Rumceisz May 14, 2012

Hi Bob,

thanks for the suggestion!

It would be the most simpliest solution, but we have a strict plugin policy, so we have to test the plugins first and then implement. Unformtunately we don't have the CLI and cache plugins?

Is there a macro for this? Or a different solution with plugins?

We don't need csv export, I would like to display on a page (like the macros I posted above).

Thanks in advance!

Rumi

The CLI function can be run from the command line directly without any plugins. So, you can get the information immediately. However, if you need something to show within Confluence then you need at least some plugin. If you do the table plugin and add the csv produced by the command line as an attachment.

Rumceisz May 14, 2012

Ok, but we don't need to export. As I see this is because the csv plugin is used. We want to display everything on a page (like the macros above).

0 votes
Rumceisz May 14, 2012

Any idea for a macro?

0 votes
Pamela Cole Mar 31, 2017

Are there any resolutions to this yet? 5 years later, and this is still something I need to figure out how to do? Does anyone have a solution for seeing all granular permissions for all spaces, in a concise report?

thanks, Pam

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

917 views 0 19
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you