Is there a way to get the last login time from an SPUser object? I don't want the last login time to Active Directory, but specifically for the sharepoint site.

2 Answers 2


To my knowledge there is no direct way to retrieve this easily. Enabling Audit logs is not a good call as it creates a lot of data for nothing, and particularly it is per Site Collection, which leaves the question : "do you enable this for all site collections?" - you are in for a tremendous amount of information - weight that carefully.

In the past we've used 2 approaches:

  1. For SharePoint foundation we've build a simple HttpModule which does nothing else but recording some information we wanted to track user behaviour across many sites, etc.
  2. For SharePoint Standard and beyond, we used custom properties (which user could not change) and stored that in his User profile directly (SharePoint API is quite rich in this direction)
  • Good point! The audit logs are very heavy and would provide a great amount of useless info if not leveraged properly. However, if you are using them already, they are helpful for this purpose.
    – Realistic
    Commented Mar 14, 2013 at 21:51

Your best bet on the sharepoint side would be the audit logs. You can enabled it to show a good amount of activity. So for your purpose, a login would most likely constitute a masterpage read. which would show up as:

Username viewed Document:site/_catalogs/masterpage/default.master

More on audit logs

  • So does that mean there is not a way to do this programatically?
    – BlueBird
    Commented Mar 14, 2013 at 19:57
  • You can use powershell and the object model. But are you referring to retrieving the audit log information or simply to enable it?
    – Realistic
    Commented Mar 14, 2013 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.