0

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

1 Answer 1

0

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
2
  • Hi @Andrew - Thanks for your reply.Your suggestion works fine for other events but once the user has been deleted,there is no way to get the username based on the id(or is there??).Do you see my problem now? Commented May 29, 2013 at 1:48
  • If user has been deleted from group, web.AllUsers collection would still contain that SPUser item and you are able to get it.
    – Andrew
    Commented May 29, 2013 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.