I’m writing to the Application event log from an ASP.NET webapp. How can I populate the “User” field of the log entry?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The user that is recorded in the event log entry is the user that “owns” the thread (from a security perspective) at the time the event logging call was made. In an ASP.Net application (by default) this will be the account that ASP.Net is running under.
You can change which user a thread is running under using windows impersonation. For an example question on SO, see:
Windows Impersonation from C#
This is a non-trivial area, and not a case of simply supplying user details to the event logging call.