我遇到了一个问题,这使我感到震惊。我正在编写一个HTTPModule,该HTTPModule检查所有HTTP请求的URL,以记录哪些用户在文档库中下载每个文档的URL。登录服务器计算机时,一切都按照应有的方式工作。但是,当从网络中的另一台计算机上登录时,似乎偶尔没有使用HTTP。

登录所有HTTP请求,登录到服务器时,我收到了URL的请求 http://portal.customer.local/reports/reportslib/xsht2.xlsx 每当下载文档时。从网络中的另一台计算机查看文档时,通常会出现此请求。但是,在查看办公室文档时,有时会请求 http://portal.customer.local/reports/_vti_bin/cellstorage.svc/cellstorageservicentlm 反而。我认为这可能是某种服务功能,并且可以肯定的是,在检查此请求的标题时,我找到了字段

SOAPAction=%22http%3a%2f%2fschemas.microsoft.com%2fsharepoint%2fsoap%2fICellStorages%2fExecuteCellStorageRequest%22

因此,我猜想肥皂是用来重新归还文档的,也许如果已在某处缓存或与所涉及的办公应用程序有一些特殊连接。

因此,分为两部分的问题:

(1)有人知道这里发生了什么事吗?有没有办法解决它?

(2)必须有一些更简单的方法来做到这一点。我的目标只是在下载文档时登录文档名称和用户名。我忽略了什么吗?

class FileDownloadedEvent : IHttpModule
{
    public void Init(HttpApplication context)
    {
        // Register event handler to be called after every page request
        context.PostAuthenticateRequest += ContextPostAuthenticateRequest;
    }

    static void ContextPostAuthenticateRequest(object sender, EventArgs e)
    {
        var app = sender as HttpApplication;
        if (app != null)
        {

            string requesturl = app.Request.Url.ToString();


                    // Inspect request url to see whether it's a request to download a document from the document library
                    if (requesturl.StartsWith(Utils.reportsLibraryUrl) && (!requesturl.Contains(".aspx")) && (!requesturl.EndsWith("/")))
                    {
                        SPWeb web = SPContext.Current.Web;

                        String fileName = requesturl.Substring(Utils.reportsLibraryUrl.Length);

                        // Call event handler action to register downloaded document
                        web.AllowUnsafeUpdates = true;
                        EventHandlerActions.documentDownloaded(web, requesturl, fileName);
                        web.AllowUnsafeUpdates = false;
            } 
        }
    }


    public void Dispose() { }

}
有帮助吗?

解决方案

您可以在SplistItem的“视图”事件上启用审核。然后可以 询问 有类似的东西:

SPSite site = ...
SPListItem item = ...
SPAuditQuery query = new SPAuditQuery(site);
query.RestrictToListItem(item);
SPAuditEventType[] eventTypes = new SPAuditEventType[] { SPAuditEventType.View };
SPAuditEntryCollection auditLog = site.Audit.GetEntries(query);

其他提示

听起来您正在重新发明轮子。 SharePoint用审核基础架构船舶船舶虽然有缺陷,但可能会为您提供所需的东西。

看看以下内容:

  1. 使用WSS3或SharePoint Foundation时,您将无法获得用户界面,因此您需要 以编程方式设置和查询. 。 (2007年的文章,但在2010年起也是如此)
  2. 使用Moss 2007或SharePoint Server 2010 您会得到一些内置的功能. 。不过,报告可能有点货。
  3. 获得第三方组件 无论您的共享环境如何,都没有所有的错误,都可以为您带来一切。

请注意,指向第三方组件的链接指向我从事的产品,以便适用通常的免责声明。

许可以下: CC-BY-SA归因
scroll top