SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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)
share|improve this answer
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 Mar 14 '13 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

share|improve this answer
So does that mean there is not a way to do this programatically? – BlueBird Mar 14 '13 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 Mar 14 '13 at 20:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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