How to list all users last login


(Mpirani) #1

I need to list all users in a particular group last login time/date is this possible?


(Anthony Barnes) #2

Last login time is not exposed as a value you can display in a listing, however Matrix does log these things internally. I wouldn't consider this best practice since you'd be exposing internal information of the system but you could setup a DB Data Source to run a query on the Matrix database to extract the 'system.security.login' from the 'type' column of the 'sq_internal_msg' table where 'userfrom' is the assetid of the user you want to find last login. Be very very careful about exposing that kind of information though, it is meant to be kept internal so you'd want to add sufficient permissions around the data. The date information would be in the 'sent' column of that table.


If you didn't want to produce a list of this for display in Matrix, but rather just view it internally then you could just run the query against the database without creating any DB Data Source assets (ie, from the command line).



There are some other gotchas:


  • I couldn't vouch for the speed of that query either since that table can get very very large.
    [*]Sometimes users don't log off - they leave a session open. Actual login time can be difficult to determine when sessions don't expire and session expiry can be customised in Matrix.

#3

Thanks anthony, it was more to find out which users haven’t logged on for a long time to cull some accounts. I used the search and found some options.


(Marcus Fong) #4

One thing to note here is that Anthony wrote that response in 2012, and last login date was added to Matrix as a user attribute in 2014.


(David Schoen) #5

https://matrix.squiz.net/manuals/keyword-replacements/chapters/global-keywords

%globals_user_attribute_login_date% - The date of the current user’s last login.