Is it possible to add custom macro to display user and corresponding group membership?

Balvant Biradar August 27, 2024

Hi All, 

I tried below macro code using below link but it is showing blank

## Developed by: Author

## Date created: 20/08/2024

##@param User:title=User|type=string|required=true|desc=Enter a user name.
<ul> 

#foreach($group in $userAccessor.getGroupNamesForUserName($paramUser))
<li>$group</li>
#end
</ul>


https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-see-which-all-groups-I-am-in/qaq-p/528042

2 answers

1 vote
Nicolai Sibler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2024

Hi @Balvant Biradar ,

we've been using the same macro for a long time. Please make sure that you

  1. enter the username (not the full name of the user) and
  2. that the corresponding user is actually a member of at least one group.

 

Cheers,

Nicolai

0 votes
Balvant Biradar August 29, 2024

It is fixed by just adding below flag in setenv.sh file
CATALINA_OPTS="-Dmacro.required.velocity.context.keys=userAccessor ${CATALINA_OPTS}"
Macro will return groups  for passed username

Working enhanced code

-------------------------------------------------------------------------
## Developed by: Balvant
## Date created: 20/08/2024
## It is not supported in versions released after 7.19+ versions
## To work you can add CATALINA_OPTS="-Dmacro.required.velocity.context.keys=userAccessor ${CATALINA_OPTS}" in setenv.sh
## @Param User:title=User|type=string|required=true|desc=Enter a user name.
<ol>
<b>User $paramUser is part of below groups if user is active</b>
#foreach($group in $userAccessor.getGroupNamesForUserName($paramUser))
<li>$group</li>
#end
</ol>
----------------------------------------------------------------------------------------------

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.19.21
TAGS
AUG Leaders

Atlassian Community Events