Hi...
I'm working with the Audit framework in MOSS 2007, and I've programatically enabled Auditing for 2 specific lists in a bunch of sites in a site collection(meaning the sites all have their own two lists). I've only enabled the update mask, as I only want to know when something's been changed or added.
However, I'm only able to log when something's been added, with my current setup. To allow for seeing changes to the list items, I'm aware that the list item itself has to have auditing enabled. But when adding a new item to the list, how do I automatically enable Auditing for the item? If possible, I'd prefer to avoid creating an event receiver to accomplish this.
*EDIT
The code I use to enable auditing looks something like this:
foreach (SPSite site in webApp.Sites) {
foreach (SPWeb website in site.AllWebs) {
website.Lists["MyList"].Audit.AuditFlags = SPAuditMaskType.Update;
website.Lists["MyList"].Audit.Update();
}
}
And to read it:
SPUserToken sysAdmin = website.Site.SystemAccount.UserToken;
using (SPSite elevatedSite = new SPSite(website.Site.ID,sysAdmin)) {
using (SPWeb elevatedWeb = elevatedSite.OpenWeb(website.ID)) {
SPAuditQuery auditQuery = new SPAuditQuery(elevatedSite);
auditQuery.SetRangeStart(myDatetime);
auditQuery.RestrictToList(elevatedWeb.Lists["MyList"]);
listChanges = elevatedWeb.Lists["MyList"].Audit.GetEntries(auditQuery);
}
}
I realize I'm restricting to list here, but when I didn't I got changes from other lists on the site as well. Even though logically I'd assume I only got the changes from the list I called "GetEntries" on...
Thanks