I was wondering if it is possible to add custom information to the Eventdata field in audit log table.I am specifically interested in the Security group and Security group member delete events.By default, these events only have the GroupId and EventID in the EventData field. My question is: Is it possible to add the GroupName and Username to the Eventdata field for these events in the audit log? Reference: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spauditentry.eventdata.aspx
There is no way to add custom parameters to standard SPAuditEventType's EventData.
But you could get GroupName and UserName in your code from ids. To do it, try that code:
var xml = new XmlDocument(); xml.LoadXml("<event>" + entry.EventData + "</event>"); XmlNode userNode = xml.SelectSingleNode("/event/userid") ?? xml.SelectSingleNode("/event/user"); int userId = Int32.Parse(userNode.InnerText); int groupId = Int32.Parse(xml.SelectSingleNode("/event/groupid").InnerText); SPUser user = web.AllUsers.GetByID(userId); SPGroup group = web.Groups.GetByID(groupId); // use group.Name and user.Name