today I found myself wondering if I check when a CRM instance was last used. We have a bunch of CRM instances and I was wondering when or if they were being used.
I was a bit dissappointed not to find anything within CRM 2011 but then I found this article which had a piece of SQL code which could do the trick. I guess this would probably work for CRM 4.
You need to run the query against the MSCRM_CONFIG database. When I ran the query it returned null for the user name but it did return the time . You will have to join a few more tables to get the user name.
In Microsoft Dynamics CRM 2011 you can get the last login time of a CRM user by using the below query:
AuthInfo, O.FriendlyName, SUO.LastAccessTime
LEFT JOIN SystemUserAuthentication SUA ON SUO.UserId = SUA.UserId AND LEFT(AuthInfo, 1)=’C’
LEFT JOIN Organization O ON SUO.OrganizationId=O.Id
LastAccessTime IS NOT NULL
ORDER BY SUO.LastAccessTime DESC
The query outputs the systemuser name, the organisation name and the date and time of the last login:
email@example.com OrganisationName 2011-03-23 16:36:13.457
You can finetune the query to your own wishes.