473,386 Members | 1,693 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,386 software developers and data experts.

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.SecurityException ("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 EventLogInstaller) 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_MACHINE\SYSTEM\CurrentControlSet\Servic es\Eventlog 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.WriteEntry("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.MachineName, "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*****@newsgroup.nospam
Nov 19 '05 #1
5 1622
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.microsoft.com> wrote in message
news:kD***************@TK2MSFTNGXA01.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.microsoft.com> wrote in message
news:ND**************@TK2MSFTNGXA02.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
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"...
1
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....
3
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...
1
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...
14
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...
7
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...
8
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...
18
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...
1
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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,...

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.