Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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
share|improve this answer
    
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? –  user1630812 May 29 '13 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 May 29 '13 at 11:50
    
Querying AllUsers did the trick.Thanks a lot! –  user1630812 May 30 '13 at 3:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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