Hi All,
I have a requirement where we need to get the user last login on AEM server i.e. User last access date & time. We are going with AEM-SAML integration for user authentication not a custom login approach. Could you let me know is there any way through which we can get above details i.e last login & no.of logins of user. Let me know if do we need to follow any approach for getting above details.
Thank you.
Sailaxman
Solved! Go to Solution.
Views
Replies
Total Likes
It won't impact the existing AEM default login functionality. All you need to do is extends the AuthenticationHandler and override the method extractCredentials and write the logic the persist the login count for user.
For rest of the method, just return the standard as it's their OOTB. E.g. acs-aem-samples/SampleLoginHookAuthenticationHandler.java at master · Adobe-Consulting-Services/acs-...
@Reference(target = "(service.pid=com.day.crx.security.token.impl.impl.TokenAuthenticationHandler)")
private AuthenticationHandler wrappedAuthHandler;
Get the OOTB authentication handler and then use the reference to return logic as its return in OOTB authentication handler.
return wrappedAuthHandler
.extractCredentials(httpServletRequest, deferredRedirectResponse);
This way you won't impact OOTB login and you'd be able to persist login count.
Views
Replies
Total Likes
Could you please describe where you want to use the last login and number of times user logs in details?
Views
Replies
Total Likes
Will not use those, will take report of Users with above details to pull & validate.
Views
Replies
Total Likes
There's a OOTB report to generate Users report but it doesn't have information related to login or number of times login in options.
And, I don't think there's such option available OOTB to get the such details.
For that, you can write custom code (a servlet) to get last login (date/time) for user. It's stored under path /home/users/<user>/.tokens/<last login node>
<last login node> - node name is the last login date and time. However, it's just last login information. You still won't find number of times user logged in information. For that, you can write custom authentication handler and once a user log-in, you can save the count in user profile and then generates the report.
Hope it helps.
Ok, does this custom authentication handler will impact my existing aem default login functionality behavior if yes then what care needs to be taken ?
Views
Replies
Total Likes
It won't impact the existing AEM default login functionality. All you need to do is extends the AuthenticationHandler and override the method extractCredentials and write the logic the persist the login count for user.
For rest of the method, just return the standard as it's their OOTB. E.g. acs-aem-samples/SampleLoginHookAuthenticationHandler.java at master · Adobe-Consulting-Services/acs-...
@Reference(target = "(service.pid=com.day.crx.security.token.impl.impl.TokenAuthenticationHandler)")
private AuthenticationHandler wrappedAuthHandler;
Get the OOTB authentication handler and then use the reference to return logic as its return in OOTB authentication handler.
return wrappedAuthHandler
.extractCredentials(httpServletRequest, deferredRedirectResponse);
This way you won't impact OOTB login and you'd be able to persist login count.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies