非管理员用户如何访问审核日志?
我正在为 SharePoint 2010 构建 Web 部件,我发现当我执行以下代码时,非管理员用户收到 Access Denied
错误消息(错误在最后一行抛出) :
SPAuditQuery wssQuery = new SPAuditQuery(web.Site);
wssQuery.RestrictToUser(web.CurrentUser.ID);
wssQuery.AddEventRestriction(SPAuditEventType.View);
wssQuery.RestrictToList(SPContext.Current.List);
SPAuditEntryCollection auditCol;
auditCol = web.Site.Audit.GetEntries(wssQuery);
如何让非管理员用户从 Web 部件访问此日志?因为我需要按非管理员用户进行过滤,即使当时非管理员用户已登录。
I'm building a Web Part for SharePoint 2010 and I've found out that non-admin users are getting Access Denied
error message when I execute the following code (the error is thrown in the last line):
SPAuditQuery wssQuery = new SPAuditQuery(web.Site);
wssQuery.RestrictToUser(web.CurrentUser.ID);
wssQuery.AddEventRestriction(SPAuditEventType.View);
wssQuery.RestrictToList(SPContext.Current.List);
SPAuditEntryCollection auditCol;
auditCol = web.Site.Audit.GetEntries(wssQuery);
How can I let non-admin users access this log from the web part? Because I need to filter by nono-admin users, even if a non-admin user is logged in at that moment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.NET Reflector 告诉我,
SPAuditEntryCollection GetEntries(SPAuditQuery query)
方法在尝试检索数据之前会执行以下检查:您可以考虑:
查询
dbo.AuditData
直接表(通常不鼓励直接访问 SharePoint 数据库,但您将进行只读访问,因此不会导致任何问题),创建自定义 SharePoint Web 服务- 这应该很简单,因为它需要做的就是执行
GetEntries
方法并返回结果。.NET Reflector tells me that the
SPAuditEntryCollection GetEntries(SPAuditQuery query)
method performs the following check before it attempt to retrieve data:You can consider:
querying the
dbo.AuditData
table directly (accessing SharePoint database directly is generally discouraged, but you'll read-only access, so it shouldn't cause any problems),creating a custom SharePoint Web service - this should be simple, because all it needs to do is execute the
GetEntries
method and return the result.