Windows 2008 IIS 7 ASP.NET 写入 Event Log 发生 安全性例外状
Windows 2008 IIS 7 ASP.NET 写入 Event Log 发生 安全性例外状况 这篇文章,将说明在 IIS 下使用 ASP.NET 写入自定 Event Log 所发生的问题,如何透过 ProceessMonitor 来观察出问题的方式。
情境: 你可能是接手站台的转移,这个站台记录相关启动资讯或系统错误的资讯,是透过自定 EventLog 方式,将相关资讯记录下来, if (!(EventLog.SourceExists("MySource"))) { EventLog.CreateEventSource("MySource","myNewLog"); } // Write an informational entry to the event log. EventLog.WriteEntry("MySource","写入 MySource");
安全性例外状况 描述: 应用程序尝试执行安全原则不允许的作业。如果要授与这个应用程序所需的权限,请联系您的系统管理员,或在组态档中变更这个应用程序的信任层级。 ?
? 在这个错误的同时,我们可以透过 ProceessMonitor 来观察问题发生点,会发现是在 Registry 没有自定的 MySource ,
? 解决步骤:1. 开始 - 执行 – regedit 2. 在 HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventlogApplication? 建立 自定的名称 ? 结果:再度执行原本的程序,就能看到正常的写入,从 ProcessMonitor 也看到正常的运行。
?
备注: 1.在其他的参考解决连结中,有特别再给予 Network Service 角色 Full Control 权限在 HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventlog , ex: 你可以使用这段程序进行测试 EventLog.WriteEntry("Application","写入 Application"); 2.如果需要自动化的建立,可参考 KB329291 ,透过 EventLogInstaller? 的方式。 ? ? 参考连结 PRB: "Requested Registry Access Is Not Allowed" Error Message When ASP.NET Application Tries to Write New EventSource in the EventLog IIS7: Web Application writing to Event Log generates Security Exception
原文:大专栏 ?Windows 2008 IIS 7 ASP.NET 写入 Event Log 发生 安全性例外状况 (编辑:ASP站长网) |