My organization's Confluence instance (v6.15.4) uses LDAP for authentication. Currently we have 4 user groups in Confluence that fall under the Licensed Users category, including a read-only group. As an admin, I receive requests to allow access for specific users and I do this by adding them to one of these groups ("confluence-users"). When we near the license limit my team and I review our record-keeping spreadsheet that tells us the last login of users. If they have not logged in for 6 months or more we remove them from the user group so that they no longer consume a license.
This hasn't been very efficient because my team and I have been receiving an influx of requests due to project demand. I wanted to see if there was a way to check this information in the backend so that we don't have to keep going back to the spreadsheet.
Thank you,
Rehnuma
Hi,
I use a user macro to generate a nice little report...
## @param group:title=Group|type=string|required=true|desc=Usergroup|default=confluence-users
#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($now=$content.currentDate.time)
#set($group = $userAccessor.getGroup($paramgroup))
#if($group)
#set($usernames = $userAccessor.getMemberNames($group))
#end
#set($totalactiveusers = 0)
<table class="confluenceTable" width="660px">
<tr>
<th class="confluenceTh">Name</th>
<th class="confluenceTh">Last Loging</th>
<th class="confluenceTh" style="text-align:center;">Days/Status</th>
</tr>
#foreach($username in $usernames)
#set($t3="9999")
#set($user = $userAccessor.getUser($username))
<tr>
<td class="confluenceTd">#usernameLink($user.name)</td>
<td class="confluenceTd" style="text-align:center;">$action.dateFormatter.formatGivenString('yyyy-MM-dd HH:mm',$loginManager.getLoginInfo($user).lastSuccessfulLoginDate)</td>
#if($loginManager.getLoginInfo($user).lastSuccessfulLoginDate)
#set($t3= $now - $loginManager.getLoginInfo($user).lastSuccessfulLoginDate.time)
#set($t3= $t3/1000/24/60/60)
#end
<td class="confluenceTd" style="text-align:center;">
#if($userAccessor.isDeactivated($user))
<ac:macro ac:name="status">
<ac:parameter ac:name="colour">Red</ac:parameter>
<ac:parameter ac:name="title">Locked</ac:parameter>
</ac:macro>
#else
#set($totalactiveusers = $totalactiveusers + 1)
#if($t3 < 7)
<ac:macro ac:name="status">
<ac:parameter ac:name="colour">Green</ac:parameter>
<ac:parameter ac:name="title">$t3</ac:parameter>
</ac:macro>
#elseif($t3 < 31)
<ac:macro ac:name="status">
<ac:parameter ac:name="colour">Blue</ac:parameter>
<ac:parameter ac:name="title">$t3</ac:parameter>
</ac:macro>
#elseif($t3 < 180)
<ac:macro ac:name="status">
<ac:parameter ac:name="colour">Yellow</ac:parameter>
<ac:parameter ac:name="title">$t3</ac:parameter>
</ac:macro>
#else
<ac:macro ac:name="status">
<ac:parameter ac:name="colour">Red</ac:parameter>
<ac:parameter ac:name="title">$t3</ac:parameter>
</ac:macro>
#end
#end
</td>
</tr>
#end
</table>
<p>Active users is group <b>$paramgroup</b>: $totalactiveusers</p>
As formatting gets f$%# even when I try using a code block, you might like to copy & paste it to notepad or something similar before creating the macro in Confluence.
Example Screenshot (I removed the user names...).
Hope this helps.
Best
JP
Hi JP,
Thanks for your quick response.
I've never used macros with Confluence. Will it change anything on the UI? Will it retrieve information from all of the 4 groups we have set up?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
no, it won’t change the UI. The macro generates a standard Confluence table and generates other macros for the status display. This macro needs a group name parameter (default to confluence-users). I would create a page with multiple instances of the macro with different group names.
You can modify the macro to your needs.
User macros can be very powerful. Give them a try.
Best
JP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great user macro! Thanks for sharing!
Regards, Dominic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So I tried adding the macro but for some reason it won't show up in the macro browser. I'm not sure if I'm setting this up correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's also this app:
Manage Inactive Users for Confluence
that will manage inactive users in Confluence for you :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Jimmy. As I've mentioned above to Ivan we want to avoid installing plug-ins at the moment. We have a protocol to get them reviewed by our security team before installing, which tends to be a lengthy process.
Thanks for suggesting!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Rehnuma Noor , I've answered a similar question to this one at
I would take a look at the post I mentioned. Perhaps, it will also help you here.
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Ivan. I see that the recommendation is to use "User Management for Confluence" however, we want to avoid plug-ins to see of there's a workaround like a query or macro, as JP suggested. Appreciate the feedback!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're very welcome 😊
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.