ASPNET can't write in event log on win XP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm trying to write in the event log and it looks like it's any of my
applications which are called by ASP.NET that are having trouble with event
log. Here's the
error:

System.InvalidOperationException: Cannot open log for source {0}. You may
not have write access. ---> System.ComponentModel.Win32Exception: Access is
denied

I didn't have this problem on windows 2000. But since I'm on Win XP now, I
have to solve this. I set full control to everyone on every drive of my
computer and it still not working...

Any idea of how to set permissions so ASPNET can write in event log in Win Xp?

Thanks,

Steph
 
see http://support.microsoft.com/default.aspx?scid=kb;en-us;842795

Yes the default registry permissions on XP/2003 are tighter than on 2000.

The first time your app tries to write to the event log, it checks to see if
an event source for your application (typically the application name)
already exists. If not, it tries to create it.

Event log sources are stored in the registry under:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\...

Changing file system permissions will have no effect on the registry. If you
start regedit.exe and locate the registry key above, right click and select
'Permissions' you can see which accounts do have access.
You could just add the ASPNET account here, but this is a BAD idea because
it will complicate deployment of your application and weaken security.

The usual solution is to create the event source at installation time using
EventLog.CreateEventSource (or the EventLogInstaller class). Installation
will normally be done in the context of an administrator account.

Here's a couple of links to get you started:
http://msdn.microsoft.com/library/d...bwlkWalkthroughCreatingEventLogInstallers.asp
http://msdn.microsoft.com/library/d...gyourapplicationassourceofeventlogentries.asp
 
Hi,

Thanks for your answer. The event source already exists. It has been created
by my application at the time it's not called by ASPNET (I also have a server
running as a service which logs the same event source).

So, since the entry is already created, why can't I write new logs with
ASPNET?

Any other idea?

Thanks,

Steph
 
¤ Hi,
¤
¤ Thanks for your answer. The event source already exists. It has been created
¤ by my application at the time it's not called by ASPNET (I also have a server
¤ running as a service which logs the same event source).
¤
¤ So, since the entry is already created, why can't I write new logs with
¤ ASPNET?
¤

Because the user account your web application is running under (probably ASPNET) does not have
sufficient permissions. I think that is what richlm was implying. See the following:

http://msdn.microsoft.com/library/d...tml/vbconsecurityramificationsofeventlogs.asp


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
As I previously said, I added ASPNET to the administrators group and it still
saying access denied... Administartors are supposed to have all needed
rights, aren't they?

Thanks,

Steph
 
Just a guess, but did you stop and restart IIS?
Stephane said:
As I previously said, I added ASPNET to the administrators group and it
still
saying access denied... Administartors are supposed to have all needed
rights, aren't they?

Thanks,

Steph
 
Of course I did! ;-)

I solve my problem using impersonation in web.config like this...

<identity impersonate="true" userName="stephane" password="12345"/>

I guess this is not te best way, but at least it's working on my development
server.

Thanks,

Steph
 
¤ Of course I did! ;-)
¤
¤ I solve my problem using impersonation in web.config like this...
¤
¤ <identity impersonate="true" userName="stephane" password="12345"/>
¤
¤ I guess this is not te best way, but at least it's working on my development
¤ server.
¤
¤ Thanks,
¤
¤ Steph

That's interesting. You weren't using Anonymous authentication w/impersonation when it wasn't
working were you?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top