Event Log SecurityException for Web Application?

☆樱花仙子☆ 提交于 2019-12-08 06:52:39

问题


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?


回答1:


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




回答2:


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).




回答3:


Nothing of these worked out for me. What did the trick was alter the Application Pool Identity from "ApplicationPoolIdentity" to "LocalSystem". Then put LocalSystem Windows account into the Administrators group.



来源:https://stackoverflow.com/questions/292883/event-log-securityexception-for-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!