How to write an entry to the Windows Security log shown by Event Viewer
A customer has engaged us to write a piece of software for them that can post entries to the Windows Security log in the Event Viewer (as opposed to the Application log). They're mostly a VB shop. With VB writing to the Windows Application log is fairly straightforward (at least in the older .NET Framework) by using the EventLog class.
But writing to the Windows Security log doesn't seem nearly as straightforward. Our customer hasn't been able to find anything helpful, and Windows security isn't our area of expertise. They engaged us simply because we've done work for them before (not related to Windows security).
Most of my research seems to center around the C function AuthzReportSecurityEvent() as the mechanism to write to the Security log. The fact that it's C doesn't bother me, since there are ways for VB code to call C code.
I have written a C program that does post an entry into the Security log using a call to this function where I guessed at some of the arguments. I have some questions about the entry that gets logged. I expect I need to flesh out the function call.
- In the Keywords column, instead of just Audit Success, it says "Classic, Audit Success". Is there a way to eliminate the Classic keyword there?
- The text that is shown in Event Viewer says "The description for Event ID <n> from source <x> cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted." How can I eliminate this text?
- The text also says "The message resource is present but the message was not found in the message table". Again, how can I eliminate this text?
- The Task Category column has (3) as the value. Can I establish a better value for that?
- I passed two string optional arguments. In the XML rendering of the entry, these two arguments show up like this:
<EventData>
<Data>value 1</Data>
<Data>value 2</Data>
</EventData>
Is there a way to get more meaningful tags for those values? In particular, I'd like something like this that I've seen in other Security log entries:
<Data Name="TargetUserName">value 1</Data>
<Data Name="IpAddress">value 2</Data>