Audit(查看审核/审计信息)
2013需要到 网站集管理-网站集审核设置 中设置要开启的审核项,开启之后sharepoint才会记录信息,信息存储在contentDB的AuditData中;
去读审计信息的sharepoint代码如下:
1 using (SPSite site = new SPSite(SiteUrl)) 2 { 3 using (SPWeb web = site.RootWeb) 4 { 5 SPAuditQuery auditQuery = new SPAuditQuery(site); 6 SPAuditEntryCollection auditEntryCollection; 7 auditEntryCollection = site.Audit.GetEntries(auditQuery); 8 foreach (SPAuditEntry entry in auditEntryCollection) 9 { 10 SPUser user = web.SiteUsers.GetByID(entry.UserId); 11 DateTime occurred = entry.Occurred; 12 string action = entry.Event.ToString(); 13 string itemType = entry.ItemType.ToString(); 14 Guid itemID = entry.ItemId; 15 string eventData = entry.EventData; 16 17 Console.WriteLine(string.Format("{0} at time {1} {2} {3}(ID:{4})" 18 , user.LoginName, occurred, action, itemType, itemID)); 19 } 20 } 21 }
记录自定义审计信息:http://www.cnblogs.com/Sunmoonfire/archive/2007/06/08/776985.html
上面提到的开启审计项,同样可以使用代码来实现:http://www.cnblogs.com/Sunmoonfire/archive/2007/05/31/765777.html