We have a requirement where we need to return the list of users who have not logged in the last 20 days from today().
Can anyone provide a sample code/approach how to do it?
Currently we are thinking of accessing the audit-log and storing in a table for the last 20 days and comparing with the application users and taking out the logged in users.
But this is a pretty long process. We also checked for below plugins.
1.User Loging Details (v1.0.0):Has a method -GetUserLastLogin, but this is returning data of audit-log for today().
2. Plugin: Login information parser almost does the same as we thought of approaching.
(The use case is to deactivate user after certain days of inactivity, there's a setting in the Admin console but we wanted to complete few things before deactivation.)
Discussion posts and replies are publicly visible
I have used the approach you describe to do achieve this. I do not know of any other option. The implementation I delivered:
(you hadn't said what your specific use case is but this is the most likely reason you want to check, to see if the licence can be freed up)
This works really well until you hit a High Availability arrangement, as the Process to read the audit log only has visibility of the log it is running on - if server 1 then it can only see log ins for server 1, not from server 2 and server 3. We have an open enhancement request to make the Shared Logs folder accessible so we can bring together the info from the 3 HA servers into one place.
Step1 : Read last 20 days audit log file one by one and save it to DBStep 2: Then in an expression rule, fetch data and Identify the users who donot have an entry in the entire dataset