SPAuditQuery Class

Defines a query of the audit entries of the SharePoint database.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.SPAuditQuery

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
Public NotInheritable Class SPAuditQuery
'Usage
Dim instance As SPAuditQuery
public sealed class SPAuditQuery

Remarks

The fundamental scope of any query is always a site collection; but you can use the members of the class to restrict a query to particular date ranges, users, event types, lists, and list items.

This class is primarily used as a parameter to the GetEntries(SPAuditQuery) method.

You cannot use this class to query the SharePoint database for anything other than the records of audited events.

Examples

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

SPAuditQuery wssQuery = new SPAuditQuery(siteCollection);
wssQuery.RestrictToListItem(item);
SPAuditEntryCollection auditCol = site.Audit.GetEntries(wssQuery);

foreach (SPAuditEntry entry in auditCol) {
  // get info from audit log
}
Dim wssQuery As New SPAuditQuery(siteCollection)
wssQuery.RestrictToListItem(item)
Dim auditCol As SPAuditEntryCollection = site.Audit.GetEntries(wssQuery)

For Each entry As SPAuditEntry In auditCol
  ' get info from audit log
Next entry

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPAuditQuery Members

Microsoft.SharePoint Namespace

Other Resources

Item-Level Auditing with SharePoint Server 2007