473,549 Members | 2,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Event Log (long)

Hi,

I'm sure this issue has been covered before but after searching around I
can't find anything which deals with quite the same set of circumstances or
suggests an optimal solution.

The issue is, broadly, that when I try to write to the Windows Event Log
from ASP.NET code I receive a System.Security .SecurityExcept ion ("Requested
registry access is not allowed").

Originally, I thought this was a problem with creating event logs and event
sources, so I wrote a custom installer (an EventLogInstall er) which I could
use to create an event log called 'MyLog' and a source called 'MySource' at
deployment time. This was following the instructions at
http://support.microsoft.com/default...b;en-us;329291.

This works great and now I can navigate to
HKEY_LOCAL_MACH INE\SYSTEM\Curr entControlSet\S ervices\Eventlo g and see a key
called 'MyLog' with a sub-key called 'MySource'. So far so good. The problem
is that I still can't write an entry.

I've examined what is happening from the perspective of the Registry (using
Regmon) and I can see that when I execute code such as
EventLog.WriteE ntry("MySource" , "MyMessage" ), all of the keys representing
event logs are searched (possibly sequentially) for an event source called
'MySource'.

Although the ASPNET account has enough permissions to access 'MyLog' and
'MySource' (and I can even execute EventLog.Exists ("MyLog") successfully) it
isn't even getting that far because as soon as the search hits the Security
log then the process fails with an ACCESS DENIED error.

I would expect the behaviour to be to ignore such errors unless I actually
want to write to that log (which I don't) and to continue searching until
either the correct source or nothing is found. Unfortunately, it seems to
just fail as soon as it receives an ACCESS DENIED for *any* log.

I had hoped to get round this by creating an instance of the EventLog class
rather than using its static methods, like this:

EventLog el = new EventLog("MyLog ", Environment.Mac hineName, "MySource") ;
el.WriteEntry(" MyMessage");

However, even this fails (on the second line) because the EventLog
constructor doesn't appear to do anything with the source except store it.
It also doesn't limit the search (described above) to the scope of 'MyLog'
and continues to bail on the Security key.

Now, I realise that there are a few ways around this problem, all of which
would probably require adding more code to my custom installer (since I want
the process to be automated):

1) Change the account under which the ASP.NET Worker Process runs to one
with suitable permissions (this seems like a manual process to me).
2) Change the permissions in the Registry either for the Security key only
or for its parent key (presuming that it inherits, I haven't checked).

I really wanted to know if there was a simpler way to do this or a
work-around because, to me, the behaviour seems bizarre. Also, what would
happen if another application created a log with extremely restrictive
permissions - would my code then bail attempting to access that log's key?

Any assistance would be appeciated!

-dan
ma*****@newsgro up.nospam
Nov 19 '05 #1
5 1632
Hi Dan,

Welcome to ASP.NET newsgroup.
As for writing Event Entreis into CustomLog. As far as I known, the
ASP.NET's default process idenity (machine\aspnet on win2k or
NetworkService on IIS6 WIN2K3) has the proper permission to write entry
into CustomLog (as long as the log exists). I think the problem you
encountered is likely to be a environment specific issue.

Are you using impersonate in your app or what's the executing account of
your asp.net application? As for the
===============
it
isn't even getting that far because as soon as the search hits the Security
log then the process fails with an ACCESS DENIED error.
=============== ===

you mentioned, it may be caused by your asp.net process identity dosn't
have read permission to the Security log. You can try granting the read
permission to the asp.net 's executing account since this is necessary if
we need to write custom log.

In addition, here is a kb article which describing the general security
setting for eventlog which maybe helpful for you to troubleshooting
EventLog's permission problem though it may not suit this issue:

#How to set event log security locally or by using Group Policy in Windows
Server 2003
http://support.microsoft.com/default...b;en-us;323076

If there are anything else we can help, please feel free to post here.
Thanks,
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 19 '05 #2
Hi Steven,

Thanks for your reply.

The ASP.NET Machine Account is running as a member of the Users group only.
I know that it can write to the custom event log but, unfortunately, this is
broken by the fact that it cannot read the Security log. If I give the
ASP.NET process the right to read the Security account then everything
functions correctly (it can now write to the custom log). This appears to be
because an attempt to write to an event log seems to fail if the process
doesn't have read permission for *all* of the event logs. You're correct
that I can manually change the permissions here - it is just that having to
give access permissions to a event log (Security) that I have no desire to
read, just to be able to write to my custom event log seems
counter-intuitive. It also doesn't seem very secure - I only want my
application to have permissions for the custom event log not access to any
of the others (but I'd settle for the defaults).

Also, I really just expected this to work but it is begining to look as if I
have to add more custom code to the installer in order to set particular
permissions for registry keys, or amend group policies, or whatever. As you
suggest, this may well be environment specific otherwise I would have
expected many people to be beating their heads against this issue. It is,
however, difficult to diagnose why my environment (a pretty clean XP
install) would be much different from anyone else's.

-dan

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:kD******** *******@TK2MSFT NGXA01.phx.gbl. ..
Hi Dan,

Welcome to ASP.NET newsgroup.
As for writing Event Entreis into CustomLog. As far as I known, the
ASP.NET's default process idenity (machine\aspnet on win2k or
NetworkService on IIS6 WIN2K3) has the proper permission to write entry
into CustomLog (as long as the log exists). I think the problem you
encountered is likely to be a environment specific issue.

Are you using impersonate in your app or what's the executing account of
your asp.net application? As for the
===============
it
isn't even getting that far because as soon as the search hits the
Security
log then the process fails with an ACCESS DENIED error.
=============== ===

you mentioned, it may be caused by your asp.net process identity dosn't
have read permission to the Security log. You can try granting the read
permission to the asp.net 's executing account since this is necessary if
we need to write custom log.

In addition, here is a kb article which describing the general security
setting for eventlog which maybe helpful for you to troubleshooting
EventLog's permission problem though it may not suit this issue:

#How to set event log security locally or by using Group Policy in Windows
Server 2003
http://support.microsoft.com/default...b;en-us;323076

If there are anything else we can help, please feel free to post here.
Thanks,
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #3
Thanks for your followup Dan,

Yes, read permission is a very basic access permission and by default the
local users group will have this permission. So I'm not sure why your
machine's users group didn't have that permission. Anyway, in most cases,
you can assume that the target box should have read permission granted to
the users group and you can do some further verification in your installer
if necessary.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #4
Steven,

Thanks a lot for your assistance. You are correct - I went to deploy on the
production server and it already had the correct registry permissions set.
Thanks again.

-dan

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:ND******** ******@TK2MSFTN GXA02.phx.gbl.. .
Thanks for your followup Dan,

Yes, read permission is a very basic access permission and by default the
local users group will have this permission. So I'm not sure why your
machine's users group didn't have that permission. Anyway, in most cases,
you can assume that the target box should have read permission granted to
the users group and you can do some further verification in your installer
if necessary.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #5
Sounds great Dan!,

Good Luck! :- )

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #6

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

Similar topics

33
2799
by: abs | last post by:
Hi all. My list: <ul> <li id="a" onclick="show(this)">Aaaaaaaa</li> <li id="b" onclick="show(this)">Bbbbbbbb</li> <li id="c" onclick="show(this)">Cccccccc <ul> <li id="d" onclick="show(this)">111111</li>
1
4226
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here. From the log it looks like the problem happens when 2 threads insert 1 record each in the same table and then try to aquire a NS (Next Key Share)...
3
4457
by: Steve Long | last post by:
Hello, I have a VB.NET class that raises a MapSet event that passes an argument of type interop.MapObjects2.MapClass. I have a C# class that inherits from this VB.NET class. How can I handle the VB.NET event in the C# class? In VB.NET, you would just write: Handles MyBase.MapSet I would appreciate any help on this.
1
3533
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say black for example). I am dynamically creating the LinkButton controls and adding them into the table cell and I've also hooked up an event handler for...
14
2109
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these grid and write to the database and I set the new Primary Keys and related Fields to the new asigned atuonumbers in the Access.
7
2546
by: Fernando Barsoba | last post by:
Hi, After following the advice received in this list, I have isolated the memory leak problem I am having. I am also using MEMWATCH and I think it is working properly. The program does some calculations and stores elements in a list. After that, a sorting algorithm is used over that list. Two functions are called before the sorting...
8
2443
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report command, even though I have the code to trap Err 2501 (from many postings - all looked the same to me) on the button the user pressed to get the...
18
2522
by: J.K. Baltzersen | last post by:
To whomever it may concern: I am using MS Visual C++ 6.0. I have a process A which instantiates an object C. At a later point the process A creates the thread B. The thread B has access to the object C.
1
2511
by: raghudr | last post by:
Hi all, I am displaying a splash screen for which i have created a thread.Since my whole project is launched by windows service and that service will start automatically at the start of the PC and sometimes when i start or restart the PC i have observed that even though the long process is completed splash
0
7521
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7473
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5369
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
764
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.