Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SPAudit.DeleteEntries Method

Windows SharePoint Services 3

Deletes all audit events that occurred before the specified date and time from the SharePoint database.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
public int DeleteEntries(
	DateTime deleteEndDate
)

Parameters

deleteEndDate
Type: System.DateTime
A DateTime representing the earliest date and time for which you want to preserve audit data.

Return Value

Type: System.Int32
An Int32 that represents the number of audit entries that were deleted.
ExceptionCondition
UnauthorizedAccessException

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

SPException

The parent object that has this SPAudit object as the value of its Audit property is not an SPSite object.

Caution noteCaution

You may call object.Audit.DeleteEntries only when object is an SPSite object.

The deletion of audit entries is itself an audited event. A call to DeleteEntries creates an entry, and the method cannot delete the entry that it makes, so at least that one entry always exists in the database even if you attempt to delete all entries.

In Windows SharePoint Services 3.0, to delete all entries (except the entry described in the preceding paragraph) you cannot simply specify the current moment for deleteEndDate with Now. You must designate a future time. We recommend the following code, where mySiteCollection is a reference to an SPSite object.

mySiteCollection.Audit.DeleteEntries(DateTime.Now.AddMilliseconds(1));
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.