views:

784

answers:

3

I have an app that writes messages to the event log. The source I'm passing in to EventLog.WriteEntry does not exist, so the Framework tries to create the source by adding it to the registry. It works fine if the user is an Admin by I get the following whe the user is not an admin:

"System.Security.SecurityException : Requested registry access is not allowed." message.

How can I fix that?

Update

I have create the registry with the Admin account manually in the registry. Now, I have the error : System.Security.SecurityException: Requested registry access is not allowed.

I do not understand because I have create a user in the Group Administrator... what do I have to do more?

A: 

The "non-programming way" is to grant the user that user your web application/web service with access to registry (Event Log are written in the event log).

Daok
I have create a User and Put it in the Administrators group. I have than in IIS select the folder and set this user in the directory security and it doesn't work. What's wrong?
Pokus
A: 

For your update I have found something that might help you :

Run regedt32
Navigate to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security
Right click on this entry and select Permissions
Add the ASPNET user
Give it Read permission

2. Change settings in machine.config file

Run Explorer
Navigate to WINDOWS or WINNT folder
Open Microsoft.NET folder
Open Framework folder
Open v1.1.4322 folder (folder name may be different, depending on what dotnet version is installed)
Open CONFIG folder
Open machine.config file using notepad (make a backup of this file first)
Locate processmodel tag (approx. at line 441)
Locate userName="machine" (approx. at line 452)
Change it to userName="SYSTEM"
Save and close the file
Close Explorer

3. Restart IIS

Run IISReset

The source is here

Daok