Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

2 Answers 2

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

 
discard

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.