Friday, November 18, 2011

Activating Auditing Programmatically for a Site Collection in Windows SharePoint

Overview
Microsoft Windows SharePoint Services 3.0 includes a powerful new infrastructure for auditing user access to list items, and documents and pages. In Windows SharePoint Services, auditing is configured on a site collection-by-site collection basis. It just takes a few lines of code to fully enable the auditing for an entire site collection. When you do this, Windows SharePoint Services writes an audit entry to its audit log each time a user views or modifies a list item, document, or site page.








Code It
Many object types in the Windows SharePoint Services object model are auditable. Each of these auditable objects exposes an Audit property. You can configure an Audit property programmatically by using a set of audit flags that is provided by the SPAuditMaskType enumeration. Start by configuring the current site collection to enable all types of auditing.

SPSite siteCollection = SPContext.Current.Site;
// Turn on auditing flags.
siteCollection.Audit.AuditFlags = SPAuditMaskType.All;
siteCollection.Audit.Update();
SPSite siteCollection = SPContext.Current.Site;
// Turn on auditing flags.
siteCollection.Audit.AuditFlags = SPAuditMaskType.View |
                                  SPAuditMaskType.Update | 
                                  SPAuditMaskType.Delete;
siteCollection.Audit.Update();
 
 
Auditing Options
While the previous example demonstrates how to enable auditing for just view, update, and delete activity, you have even more options. Following is the complete set of SPAuditMaskType values that provide control over different types of auditing.

SPAuditMaskType.CheckIn
SPAuditMaskType.CheckOut
SPAuditMaskType.ChildDelete
SPAuditMaskType.Copy
SPAuditMaskType.Delete
SPAuditMaskType.Move
SPAuditMaskType.ProfileChange
SPAuditMaskType.SchemaChange
SPAuditMaskType.Search
SPAuditMaskType.SecurityChange
SPAuditMaskType.Undelete
SPAuditMaskType.Update
SPAuditMaskType.View
SPAuditMaskType.Workflow
 
 

 

2 comments:

  1. Hi Dude,

    Microsoft windows sharePoint services 3.0 is a versatile technology that organizations and business units of all sizes can use to increase the efficiency of business processes and improve team productivity. Thanks a lot.....

    Public Folders

    ReplyDelete
  2. Hi friends,

    Microsoft windows SharePoint Services 3.0 is a versatile technology that organizations and business units of all sizes can use to increase the efficiency of business processes and improve team productivity. Thanks a lot....

    ReplyDelete

Thank you for Commenting Will reply soon ......

Featured Posts

Open Hardware Monitor A Handy Tool for System Monitoring

#Open #Hardware #Monitor: A Handy Tool for #System #Monitoring #OpenHardwareMonitor is a free, #opensource #software designed to monitor t...