I have to develop an Audit C# application, which count the number of openings of each pdf file located in a folder. I've got a regular account on which I develop the application and a another one, which has access to data of the audit. So my question is: How can I access to the EventLogs of another account from my computer?
Asked
Active
Viewed 161 times
1 Answers
0
You can use impersonation as described in this article: How do you do Impersonation in .NET?
Impersonate with different account and than use standard api to access Event Log.
-
It was my last solution, the others were: EventLogSession (but with this one, I wasn't able to connect to the machine) and WMI. Hope this one will work. Thank you ;) – Victor.L Apr 19 '16 at 14:35
-
Which LogonUser do you recommend? – Victor.L Apr 20 '16 at 13:47
-
You can use standard LoginUser from msdn - just specify LOGON32_LOGON_INTERACTIVE as you need only local access without network. – VitaliyK Apr 20 '16 at 13:54
-
Isn't LOGON32_LOGON_NEW_CREDENTIALS better? – Victor.L Apr 21 '16 at 09:27
-
According to MSDN documentation the difference is only in situations when you access network from impersonated account. So for your case - you can use both of these logon types. – VitaliyK Apr 21 '16 at 09:38
-
Thanks a lot, I made some test before and it worked well in both cases! It was a pleasure to talk with you, have a nice day! ;) – Victor.L Apr 21 '16 at 11:52