GetEntries Method (SPAuditQuery)
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

SPAudit.GetEntries Method (SPAuditQuery)

Windows SharePoint Services 3

Gets a collection of SPAuditEntry objects from the audit data stored in the SharePoint database that match the specified query.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPAuditEntryCollection GetEntries(
	SPAuditQuery query


Type: Microsoft.SharePoint.SPAuditQuery
An SPAuditQuery object that defines the kind of audit data that is returned.

Return Value

Type: Microsoft.SharePoint.SPAuditEntryCollection
An SPAuditEntryCollection that holds the requested SPAuditEntry items.


The calling code is in the context of a user who is not a site administrator.


query is a null reference (Nothing in Visual Basic).

For a simpler method that does not require you to create an SPAuditQuery object, see GetEntries.

The following example (from Item-Level Auditing with SharePoint Server 2007) shows this method in use.

SPSite oSiteCollection = (SPSite)properties.Feature.Parent;
SPAuditQuery oAuditQuery = new SPAuditQuery(oSiteCollection);
SPAuditEntryCollection collAuditEntries = oSiteCollection.Audit.GetEntries(oAuditQuery);

foreach (SPAuditEntry oAuditEntry in collAuditEntries) {
  // get info from audit log
© 2015 Microsoft