Is it possible to read out all crowd user groups with their members via user macro?
Asked by Rieger, Ralf:

Hello all,

is it possible to read out or output all existing crowd user groups with their corresponding members.  
I have made a first attempt via

```
## Macro title: Listing Confluence groups
## Macro has a body: Y
## Body processing: N
## Output: Unsorted filtered list of confluence groups
##
## Developed by: xxx
## Date created: xx/xx/20xx
## Installed by: xxx
##
## Parameters
## @noparams

#set ($Count = 0)

<h1>User groups</h1>
<hr>
<ul>
#foreach($group in $userAccessor.getGroups())
? <li>$group.Name</li>
? #set ($Count = $Count + 1)
#end
</ul>
<hr>
<h6>Group count: <b>$Count</b></h6>
```

started.  
Now I would like to replace the previous script with this

```
## Macro title: Show Group Membership
## Description: List all the members of a group
## Macro has a body: N
##
## Developed by: xxx
## Date created: xx/xx/20xx
## Installed by: xxx
##
## @param Group:title=Group Name|type=string|required=true|desc=Insert group name

#set($containerManagerClass = $action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)

#set($userAccessor = $containerManager.containerContext.getComponent('userAccessor'))
#set($groupManager = $containerManager.containerContext.getComponent("groupManager"))
#set($group = $userAccessor.getGroup($paramGroup))
#set($users = $userAccessor.getMemberNamesAsList($group))

<style type="text/css">
@media all {
.show-group-membership-macro .expand-control {
margin-bottom: 0px;
}
}
</style>

<span class="show-group-membership-macro">
<ac:structured-macro ac:name="expand" ac:schema-version="1">
<ac:parameter ac:name="title">$paramGroup</ac:parameter>
<ac:rich-text-body>
<ul>
#foreach( $username in $users )
#set($confluenceUser = $userAccessor.getUserByName($username)) 
<li><ac:link>
<ri:user ri:userkey="$confluenceUser.key" />
</ac:link></li>
#end
</ul>
</ac:rich-text-body>
</ac:structured-macro>
</span>
```

couple. Unfortunately I am missing the approach how to implement this.  
Does anyone here have an idea or a little help.

Thanks for your help


Answers:
author: Fabian Lim
body: Hi [@Rieger, Ralf](/t5/user/viewprofilepage/user-id/4656177)

Welcome to the community!

Have you been able to solve this one as I'm interested?

Regards

comments: author: Rieger, Ralf
body: Hi [@Fabian Lim](/t5/user/viewprofilepage/user-id/3131564)

currently I can read out and display/list all permissions for Viewers, Editors and Commentors (users and groups) for one space.

Unfortunately, I am still stuck on the iteration of the spaces themselves, i.e. reading out the permissions of all spaces to be displayed as an overview or as an expander for each space.

Best regards


author: Nicolas Casel
body: Hello [@Rieger, Ralf](/t5/user/viewprofilepage/user-id/4656177) ,

Many thanks for the 2nd code snippet you shared, very useful !

In the same way, to get the user email address:

```
<ri:user ri:userkey="$confluenceUser.email" />
```


Tags: confluence-server

crowd

group

macro

user