SPAudit.AuditFlags Property
Gets or sets a value indicating what kinds of events and actions are audited.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
Public Property AuditFlags As SPAuditMaskType
Get
Set
Dim instance As SPAudit
Dim value As SPAuditMaskType
value = instance.AuditFlags
instance.AuditFlags = value
public SPAuditMaskType AuditFlags { get; set; }
Property Value
Type: Microsoft.SharePoint.SPAuditMaskType
An SPAuditMaskType that encodes in a bitwise fashion the events and actions that are audited.
Remarks
Use bitwise logical operators to combine multiple SPAuditMaskType flags.
Call Update immediately after making changes to AuditFlags.
Examples
The following example shows how to change the audit settings for a list item. (The item is an object of type SPListItem.)
// Turns on auditing of user views and deletions of items.
oListItem.Audit.AuditFlags = (SPAuditMaskType.View | SPAuditMaskType.Delete);
oListItem.Audit.Update();
// Turns on auditing of user views of the list item without changing
// any other existing auditing settings.
oListItem.Audit.AuditFlags = (item.Audit.AuditFlags | SPAuditMaskType.View);
oListItem.Audit.Update();
// Turns off auditing of user views of the list item without changing
// any other existing auditing settings.
oListItem.Audit.AuditFlags = (item.Audit.AuditFlags &
(SPAuditMaskType.All ^ SPAuditMaskType.View));
oListItem.Audit.Update();
// Turns on auditing of all types of events and actions relevant to
// the list item.
oListItem.Audit.AuditFlags = SPAuditMaskType.All;
oListItem.Audit.Update();
// Turns off all auditing of the list item.
oListItem.Audit.AuditFlags = SPAuditMaskType.None;
oListItem.Audit.Update();
The following example (from Item-Level Auditing with SharePoint Server 2007) shows this property in use.
public override void FeatureActivated(SPFeatureReceiverProperties properties) {
SPSite oSiteCollection = (SPSite)properties.Feature.Parent;
// Turn on auditing flags.
oSiteCollection.Audit.AuditFlags = SPAuditMaskType.All;
oSiteCollection.Audit.Update();
// Modify title of top-level site.
SPWeb oWebsiteRoot = oSiteCollection.RootWeb;
oWebsiteRoot.Title += " (audited)";
oWebsiteRoot.Update();
SPListTemplate oListTemplate = oWebsiteRoot.ListTemplates["Document Library"];
Guid docLibID = oWebsiteRoot.Lists.Add("AuditLogs", "Library for Audit Log Workbooks", oListTemplate);
SPList oListDocLib = oWebsiteRoot.Lists[docLibID];
oListDocLib.OnQuickLaunch = true;
oListDocLib.Update();
}
See Also
Reference
Microsoft.SharePoint Namespace