K
Ken Varn
I am using the EventLog class to try and get the Security logs to display
them on my asp.net page. For some reason if I impersonate an administrator
user before accessing the Entries collection in the EventLog object, I get a
Win32Exception (A required privilege is not held by the client). However,
if I set the ASP.NET account to run under the SYSTEM level privileges
without doing impersonation, the call works fine. This only seems to be a
problem when accessing the Security EvenLog category. Can someone explain
why this occurs and how I can get it to work under impersonation, rather
than using SYSTEM level privileges for the ASP.NET account?
i.e.,
void ParseLog()
{
EventLog Log;
// Omitted - Impersonation code done here
//....
Log = new EventLog("Application");
foreach(LogEntry L in Log.Entries) // This loop works fine.
{
// Omitted -- Load log data into screen here.
}
Log = new EventLog("Security");
foreach(LogEntry L in Log.Entries) // Exception is thrown here.
{
// Omitted -- Load log data into screen here.
}
}
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
them on my asp.net page. For some reason if I impersonate an administrator
user before accessing the Entries collection in the EventLog object, I get a
Win32Exception (A required privilege is not held by the client). However,
if I set the ASP.NET account to run under the SYSTEM level privileges
without doing impersonation, the call works fine. This only seems to be a
problem when accessing the Security EvenLog category. Can someone explain
why this occurs and how I can get it to work under impersonation, rather
than using SYSTEM level privileges for the ASP.NET account?
i.e.,
void ParseLog()
{
EventLog Log;
// Omitted - Impersonation code done here
//....
Log = new EventLog("Application");
foreach(LogEntry L in Log.Entries) // This loop works fine.
{
// Omitted -- Load log data into screen here.
}
Log = new EventLog("Security");
foreach(LogEntry L in Log.Entries) // Exception is thrown here.
{
// Omitted -- Load log data into screen here.
}
}
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------