It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Macro to get User ID along with Full Name and Login Activity

We're using below macro to dynamically get the list of users in our Confluence and report their activity. It's working pretty well.

The only problem is the full name isn't helping us.

We sometimes perform lookups with other data we generate from LDAP. As our confluence is linked to LDAP having a Confluence user login ID instead of the name helps us a lot. Right now below is the block of code in our Confluence user reporting macro.

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

#set($loginManager = $containerContext.getComponent('loginManager'))
#set($crowdService = $containerContext.getComponent('crowdService'))
#set($users = $userAccessor.getUsers())

<table class="confluenceTable">
<th class="confluenceTh">User</th>
<th class="confluenceTh">Last Successful Login Date</th>
<th class="confluenceTh">Creation Date</th>
<th class="confluenceTh">Active</th>
#foreach($user in $users)
#set($crowdUser = $crowdService.getUser($
<td class="confluenceTd">#usernameLink($</td>
<td class="confluenceTd">$action.dateFormatter.formatDateTime($loginManager.getLoginInfo($user).lastSuccessfulLoginDate)</td>
<td class="confluenceTd">$action.dateFormatter.formatDateTime($crowdUser.createdDate)</td>
<td class="confluenceTd" style="text-align:center;">
<img src="/s/en_GB/3047/11/_/images/icons/emoticons/error.png" width="18" height="18" border="0">
<img src="/s/en_GB/3047/11/_/images/icons/emoticons/check.png" width="18" height="18" border="0">

I need some help with the below line to generate Confluence user id instead of user's name.

<td class="confluenceTd">#usernameLink($</td>


Thanks in advance.

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Confluence

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

32 views 2 4
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you