When I try to get the list of users with the user macro where I need the users last login and login count. But I'm unable to get that through the macro.
Is there any logic where I can get the users last login and the login count.
Macro which I've created:
## Macro title: Last Login
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Poornika Reddy Ekkati
## Macro to display the last login date of users who have access to the current space
## @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($users = $userAccessor.getUsers())
<table class="confluenceTable">
<tr>
<th class="confluenceTh">Count</th>
<th class="confluenceTh">User</th>
<th class="confluenceTh">Login Name</th>
<th class="confluenceTh">Last Successful Login</th>
<th class="confluenceTh">Directory</th>
</tr>
#set($count = 0)
#foreach($user in $users)
## list the last login date of users who can view the current space
#if($user.directoryId == 1)
#if($user.active == true)
#set($count = $count + 1)
<tr>
<td class="confluenceTd">$count</td>
<td class="confluenceTd">#usernameLink($user.name)</td>
<td class="confluenceTd">$user.name</td>
<td class="confluenceTd">$user.lastSuccessfulLoginDate</td>
##action.dateFormatter.formatDateTime($loginManager.getLoginInfo($user.name)
<td class="confluenceTd">$user.directoryId</td>
#end
#end
#end
</table>
Output which I get:
I don't think you can achieve this through the standard macro. Creating a user macro might be a solution but I can not help you with that.
Thank you patrick. I've created a user macro, but it doesn't print the Last Successful Login.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.