对列表中的新文件自动启用 SPAudit

发布于 2024-09-14 11:41:10 字数 1132 浏览 3 评论 0原文

我正在使用 MOSS 2007 中的审核框架,并且我以编程方式启用了对网站集中一堆网站中的 2 个特定列表的审核(这意味着这些网站都有自己的两个列表)。我只启用了更新掩码,因为我只想知道何时更改或添加了某些内容。

但是,在我当前的设置下,我只能在添加内容时进行记录。为了允许查看列表项的更改,我知道列表项本身必须启用审核。但是,当向列表添加新项目时,如何自动启用该项目的审核?如果可能的话,我宁愿避免创建事件接收器来完成此任务。

*编辑

我用来启用审核的代码看起来像这样:

foreach (SPSite site in webApp.Sites) {
    foreach (SPWeb website in site.AllWebs) {
       website.Lists["MyList"].Audit.AuditFlags = SPAuditMaskType.Update;
       website.Lists["MyList"].Audit.Update();
    }
}

并且阅读它:

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);
    }
}

我意识到我限制在此处列出,但是当我没有时,我从其他列表中得到了更改网站也是如此。尽管从逻辑上讲,我认为我只从我称为“GetEntries”的列表中获得了更改......

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゝ杯具 2024-09-21 11:41:10

如果图书馆启用了审核,则将审核新项目。我不知道有任何特定于文档的审核

If the library has auditing enabled, then new items will be audited. I'm not aware of any document-specific auditing

玩物 2024-09-21 11:41:10

回复这个有点晚了,但这里有一些附加信息,以防其他人找到这篇文章。

可以在文档级别跟踪审核事件。此链接解释了如何完成此操作。他们使用事件处理程序来使其工作。我知道您提到您不想这样做,但这是自动跟踪文档事件所需要的。在文档库上设置审核掩码类型似乎仅跟踪 DL 事件,而不是单个项目。

A little late in replying to this, but here is some additional information in case others find this post.

It is possible to track the auditing events at the document level. This link explains how it can be done. They use an event handler to make it work. I know you mention you do not want to do it this way, but this is what is needed to automatically track document events. Setting the audit mask type on the document library appears to only track the DL events, not the individual items.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文