How do I know which Space a Confluence group is related to ?

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

8 answers

1 accepted

0 votes
Accepted answer

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

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?

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

Thanks Lukas It works beautifully now :)

1 vote

Hi Carlos,


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;;


Hope this helps!


Kind Regards,
Jing Hwa

Hi Jing, Thanks for the reply I 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 administrator Regards Carlos

0 votes

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.

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

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

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

Which version of confluence are you on? Groups should be lowercase only.. Please test for a simple group, it works for me.

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

 

 

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?

sry getGroup().name won't work, it's a string.

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

Hi Lukas, Thanks for your patience and help I 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 #end What would be the right code to make the comparison in lower cases Kind regards Carlos

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

922 views 13 11
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