473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can't get EventLogs of type Security.

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
-----------------------------------
Nov 19 '05 #1
3 1392
my guess is that the impersonation code is incorrect. the asp.net account
need impersonation (act as part of os) permission, and you need a primary
token for the account you want to impersonate. if there is a current
impersonation you will need to revert first.

-- bruce (sqlwork.com)
"Ken Varn" <nospam> wrote in message
news:u0*************@tk2msftngp13.phx.gbl...
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
-----------------------------------

Nov 19 '05 #2
Run RegEdt32
Under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\Eventlog
Right Click on the Security key and see the permission list. This way you do
not have to grant Admin privileage for the rest of the code.

Regards,

Trevor Benedict R
MCSD

"Ken Varn" <nospam> wrote in message
news:u0*************@tk2msftngp13.phx.gbl...
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
-----------------------------------

Nov 19 '05 #3
Thanks for the info.

I checked out the permissions, and admin does have read/write permissions.
I am impersonating an admin user before using the EventLog object, but I am
still not getting permission. Maybe my impersonation logic is not right.
Here are the steps that I follow:

- First PInvoke the Win32 LogonUser to get a handle to my reserved admin
user.
- Next, I PInvoke the Win32 DuplicateToken to create a new handle of type
SecurityImpersonation
- Next, I Create a WindowsIdentity object using the duplicated handle.
- Finally, I call the Impersonate method of the WindowsIdentity object.

All calls in the above steps are checked for success and all complete
successfully.

Is there something that I am doing wrong here?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"Trevor Benedict R" <tr********@yahoo.com> wrote in message
news:uk**************@TK2MSFTNGP14.phx.gbl...
Run RegEdt32
Under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\Eventlog
Right Click on the Security key and see the permission list. This way you do not have to grant Admin privileage for the rest of the code.

Regards,

Trevor Benedict R
MCSD

"Ken Varn" <nospam> wrote in message
news:u0*************@tk2msftngp13.phx.gbl...
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
-----------------------------------


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yxq | last post by:
Hello I want to create and delete the folder share, i found that it is ok for generic folder, but it does not work for Root directory(i.e c:\, d:\) The code...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
0
by: Siberwulf | last post by:
I'm trying to fetch an XML document from a website through an assembly i built and attached to SQL 2005. Here is my code for the SPROC assembly: public static void fetch_FeedData(string...
9
by: DrBonzo | last post by:
In order to get events back from a DCOM server (an embedded device running Windows CE), I seem to have to turn off security for my process. To do this, I'm saying: int ret =...
1
by: terryspanky | last post by:
----------------------Below are all the codes don't have errors---- The only problem I have is when I Delete, I'ts not deleting the subject that I click. I want to use the above codes to modify the...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
8
by: Nivetha | last post by:
I have requirement like the first page contains LoginName and CompanyName after typing the value clicking Submit button so i am giving in body onload="document.forgotPassword.loginName.focus();...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
8
by: Neil | last post by:
I just started using Access 2003, and I can't link a SQL Server table. I right-click on the database window; select Link Tables; and select ODBC Databases from the Files of Type dropdown. As soon...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.