Determine users who have not logged in <20> days

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:

    • reads the audit log
    • loads the data into a database table
    • checked each entry to see when a User last logged in
    • sent that user a warning email if they hadn't logged in for a certain period of time (and recorded the fact that we'd sent them an email so that we didn't keep sending them the same email)
    • if they didn't log in within 3 days of their warning email then the process deactivated their account

    (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 DB
    Step 2:  Then in an expression rule, fetch data and Identify the users who donot have an entry in the entire dataset