写入事件日志时出现 System.Security.SecurityException
我正在尝试将 ASP.NET 应用程序从 Server 2003(和 IIS6)移植到 Server 2008 (IIS7).
I’m working on trying to port an ASP.NET app from Server 2003 (and IIS6) to Server 2008 (IIS7).
当我尝试访问浏览器上的页面时,我得到了这个:
When I try and visit the page on the browser I get this:
/"应用程序中的服务器错误.
Server Error in ‘/’ Application.
安全异常
描述:应用程序试图执行安全策略不允许的操作.要授予此应用所需的权限,请联系您的系统管理员或在配置文件中更改应用的信任级别.
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.
异常详细信息:System.Security.SecurityException:未找到源,但无法搜索部分或全部事件日志.无法访问的日志:安全
Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security
源错误:
在执行当前 Web 请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常来源和位置的信息.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and the location of the exception can be identified using the exception stack trace below.
堆栈跟踪:
[SecurityException:未找到源,但无法搜索部分或全部事件日志.无法访问的日志:安全.]
[SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.]
System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly) +562System.Diagnostics.EventLog.SourceExists(String source, String machineName) +251
System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly) +562 System.Diagnostics.EventLog.SourceExists(String source, String machineName) +251
[剪辑]
这些是我尝试解决的方法:
These are the things I’ve done to try and solve it:
授予所有人"对密钥
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventLogSecurity
的完全访问权限.这奏效了.但自然我不能在生产中做到这一点.所以我在运行应用几分钟后删除了所有人"权限,错误再次出现.
Give "Everyone" full access permission to the key
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventLogSecurity
. This worked. But naturally I can’t do this in production. So I deleted the "Everyone" permission after running the app for a few minutes and the error re-appeared.
我在安装过程中使用提升的权限在应用程序日志和安全日志中创建了源(并且我通过 regedit 验证了它存在),但错误仍然存在.
I created the source in the Application log and the Security log (and I verified it exists via regedit) during installation with elevated permissions but the error remained.
我在 web.config
文件(并使用 appcmd.exe
)中为应用程序提供了完全信任级别,但无济于事.
I gave the app a full trust level in the web.config
file (and using appcmd.exe
) but to no avail.
有没有人知道这里可以做什么?
Does anyone have an insight as to what could be done here?
PS:这是这个问题的后续行动.我按照给定的答案进行操作,但无济于事(请参阅上面的 #2).
PS: This is a follow up to this question. I followed the given answers but to no avail (see #2 above).
解决方案是授予网络服务"帐户对 EventLog/Security 密钥的读取权限.
The solution was to give the "Network Service" account read permission on the EventLog/Security key.