How do I know which Space a Confluence group is related to ?
Asked by Carlos Reyes:

Dear Confluence gurus,

If I have the name of a particular Confluence group that does not give a strong clue to which Space belongs to in the name then is there a way of making the query somewhere to know?

We are using Confluence 5.1.5

I appreciate any clue

Kind regards

Carlos


Answers:
author: Carlos Reyes
body: Hi LuKas the second macro works nicely

Groups today.JPG

it provides a list of all the groups by Space. Now, If I use the ITS-Confluence-IT Resources in the original macro then nothing happens. Any idea?

Thanks for your help so far

Cheers

Carlos  
[](https://community.atlassian.com/t5/Confluence-questions/How-do-I-know-which-Space-a-Confluence-group-is-related-to/qaq-p/44918?attachment-id=11963){#link_118876e3ff9331}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/7613/1/Groups%20today.JPG){#display_118876e3ff9331_0}

comments: author: Lukas Knoch -Rumpelcoders-
body: In that case it seems to be a string compare issue. Maybe try .toLowerCase()?As in:$permission.getGroup().toLowerCase() == $param0.toLowerCase()Does it work with different groups?


author: Lukas Knoch -Rumpelcoders-
body: Hi, try this:## Macro title: My Macro## Macro has a body: Y or N## Body processing: Selected body processing option## Output: Selected output option#### Developed by: My Name## Date created: dd/mm/yyyy## Installed by: My Name## This is an example macro## @param 0:title=group\|type=string\|required=true#foreach($space in $spaceManager.getAllSpaces())#foreach ($permission in $space.getPermissions())#if ($permission.isGroupPermission() \&\& $permission.getGroup().toLoweCase() == $param0.toLoweCase() )Group has permission in space $space.name \<br/\>#end#end#end


author: Carlos Reyes
body: Thanks Lukas It works beautifully now:)


author: Lukas Knoch -Rumpelcoders-
body: you are welcome :)


author: jing_hwa_cheok
body: Hi Carlos,

<br />

You can also list the spaces which the group have direct permission by querying it directly from the database.Replace the \<GROUP_NAME\> in the query with the name of the group you wish to find:

```
select SPACENAME, SPACEKEY from spaces JOIN spacepermissions ON spacepermissions.SPACEID= spaces.SPACEID where spacepermissions.PERMGROUPNAME=&lt;GROUP_NAME&gt;;
```

<br />

Hope this helps!

<br />

Kind Regards,  
Jing Hwa

comments: author: Carlos Reyes
body: Hi Jing,Thanks for the replyI appreciate your solution and I will have it as an option. The only issue in my site is that only the database administrator can query directly the database so I would have to go to him to get it done.The user macro is something that I can do myself as the application administratorRegardsCarlos


author: Carlos Reyes
body: Hi Lukas,Thanks for your patience and helpI think that the last suggestion should be a winner If I can implement it correctly. I coded this but it did not work:## Macro title: My Macro## Macro has a body: Y or N## Body processing: Selected body processing option## Output: Selected output option#### Developed by: My Name## Date created: dd/mm/yyyy## Installed by: My Name## This is an example macro## @param 0:title=group\|type=string\|required=true#foreach($space in $spaceManager.getAllSpaces())#foreach ($permission in $space.getPermissions())#if ($permission.isGroupPermission().toLowerCase() \&\& $permission.getGroup().toLowerCase()==$param0.toLowerCase())Group has permission in space $space.name \<br/\>#end#end#endWhat would be the right code to make the comparison in lower casesKind regardsCarlos


author: Carlos Reyes
body: The groups that I am interested in are not internal groups but Active Directory groups

AD Groups.JPG

These AD groups synchronize with my instance of Confluence 5.1.5

AD Sync.JPG

Any idea?

Thanks for the help so far

Carlos

[](https://community.atlassian.com/t5/Confluence-questions/How-do-I-know-which-Space-a-Confluence-group-is-related-to/qaq-p/44918?attachment-id=10610){#link_11887719ac1e5d}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/7609/1/AD%20Sync.JPG){#display_11887719ac1e5d_0}  
[](https://community.atlassian.com/t5/Confluence-questions/How-do-I-know-which-Space-a-Confluence-group-is-related-to/qaq-p/44918?attachment-id=10611){#link_11887719ac1e5d_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/7609/2/AD%20Groups.JPG){#display_11887719ac1e5d_2}

comments: author: Lukas Knoch -Rumpelcoders-
body: Ok, try it the other way round: display all groups that have permission on the space by changing the line:#if ($permission.isGroupPermission() \&\& $permission.getGroup()==$param0) to#if ($permission.isGroupPermission())Group name: $permission.getGroup().name \<br/\>Group: $permission.getGroup() \<br/\>and check if the group occurs there. maybe it has some kind of strange internal name?


author: Lukas Knoch -Rumpelcoders-
body: sry getGroup().name won't work, it's a string.


author: Carlos Reyes
body: The macro (the other way around) worked for me though it provided a list of all the groups by Space. Now, If I use the ITS-Confluence-IT Resources in the original macro then nothing happens. Any idea?Carlos


author: Carlos Reyes
body: Hi Lukas,

Thanks for the reply.

I like your approach and keen to implement it. Now, I tried to follow your instructions

Macro Code.JPG

and this what I get

Macro Result.JPG

I know that group has related Spaces and when I refresh then I get nothing so something is not quite right in my implementation . Needles to say that I have never used "User Macros" before so likely I am missing something. Any idea?

Kind regards

Carlos  
[](https://community.atlassian.com/t5/Confluence-questions/How-do-I-know-which-Space-a-Confluence-group-is-related-to/qaq-p/44918?attachment-id=5808){#link_1188772bb737b4}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/7607/1/Macro%20Result.JPG){#display_1188772bb737b4_0}  
[](https://community.atlassian.com/t5/Confluence-questions/How-do-I-know-which-Space-a-Confluence-group-is-related-to/qaq-p/44918?attachment-id=5809){#link_1188772bb737b4_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/7607/2/Macro%20Code.JPG){#display_1188772bb737b4_2}

comments: author: Lukas Knoch -Rumpelcoders-
body: Which version of confluence are you on? Groups should be lowercase only.. Please test for a simple group, it works for me.


author: Lukas Knoch -Rumpelcoders-
body: Hi,

i usually use a user macro for that.

That's the code (should work, not tested):

```
## Macro title: My Macro## Macro has a body: Y or N## Body processing: Selected body processing option## Output: Selected output option#### Developed by: My Name## Date created: dd/mm/yyyy## Installed by: My Name## This is an example macro## @param 0:title=group|type=string|required=true#foreach($space in $spaceManager.getAllSpaces())#foreach ($permission in $space.getPermissions())#if ($permission.isGroupPermission() &amp;&amp; $permission.getGroup()==$param0)Group has permission in space $space.name &lt;br/&gt;#end#end#end
```


author: Carlos Reyes
body: Hi Jobin,

Thanks for the reply. Now, will it be a way of providing a group name and then get a list of the Space (or Spaces) that it is referenced to?

Kind regards

Carlos


author: Jobin Kuruvilla [Adaptavist]
body: There is no one-to-one relation between spaces and groups. You can use groups in space permissions and that is it. But the same group might be used in many spaces.


Tags: confluence-administration