Display all the groups, users of each space

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

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

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.

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).

Any idea for a macro?

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

264 views 11 10
Join discussion

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