I have a claims-based SharePoint 2010 application that uses Forms-based authentication to authenticate the user to the site. To access the site the user goes to a URL and enters their user id and password. It verifies their Active Directory credentials and allows them to access the site under those credentials from that point forward. Hopefully I have described that correctly.

My users have requested a way to view a log of who logged in to the site and when. I'm having trouble finding out where this information is stored. It seems like this would be a common request and that I should be able to find some kind of off the shelf feature or component that handles this.

I should clarify that I know how to create a page and display the data - I just need to know how to get at the data. I assume there is some kind of authentication log built by IIS that I could read but I was hoping SharePoint had something nice built in.

  • Please refine your question to what logging into a site means to you. In my environment I never have to "login" because my browser passes my creds to the site. Are you wanting to know every time a person's browser sends their creds to the site, or just wanting to know when a user has accessed content on the site? Commented Jan 21, 2014 at 19:41

3 Answers 3


Based on the new information of this being forms based authentication, then I would suggest recording the login's in your form page's code. Unfortunately, logouts can be more difficult because of cookie expiration's and such where a user could be logged out without actually hitting any resource on the SharePoint site.


You need the site web analytics services enabled. Then, from your Site Settings page on the desired site(s), this data will be available under the 'Site Actions' section.

More info is here: http://technet.microsoft.com/en-us/library/gg266382(v=office.14).aspx


If you turn on site collection auditing (http://office.microsoft.com/en-us/sharepoint-server-help/configure-audit-settings-for-a-site-collection-HA102031737.aspx), then you can easily use the API to get the audit data. You can restrict the data to just views. See code sample below:

SPAuditQuery query = new SPAuditQuery(rootSite.Site);
SPAuditEntryCollection auditCol = rootSite.Site.Audit.GetEntries(query);
foreach (SPAuditEntry entry in auditCol)
    string user = entry.UserId.ToString();
    DateTime dt = entry.Occurred.ToLocalTime();
    string url = "/" + entry.DocLocation;

The main issue is audit data is only stored at the site collection level. If you need it for the whole web application, then you'll need to repeat this code for each site collection in the web application.

  • This looks promising but I don't see any user log in log out events as being logged in the audit log. Am I missing something? Commented Jan 21, 2014 at 19:23
  • There isn't really a login event. More that a user viewed a page. SharePoint doesn't store login events, just actions such as viewing a page, creating an item, deleting items, etc. Commented Jan 21, 2014 at 19:36
  • 1
    If you are using Forms based authentication or maybe SAML claims, then you can probably record this information yourself and then report on it. But if you are using NTLM/Kerberos, then the only way to really get at login events is through parsing the IIS logs. Look for a 401 followed by a 200 and in the 200 event should be user's login name. Commented Jan 21, 2014 at 19:38
  • Good point, I did not explain that very well. I added a paragraph at the top about how the login actually works. It sounds like creating my own log and writing to it in the login/logout code might be the easiest way to do this. Commented Jan 21, 2014 at 19:50

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.