Win7 上的 ASP.Net 中的 EventLog 权限失败
我有一个 ASP.Net 应用程序 .net 3.5 SP1,在 Win7 中运行。在登录过程中,ASP.Net 登录控件中的某些内容导致写入事件日志中的安全日志(这听起来对我来说可以接受)。问题是该应用程序似乎没有执行此操作的权限。错误为:
描述:应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请联系您的系统管理员或在配置文件中更改应用程序的信任级别。
异常详细信息:System.Security.SecurityException:请求“System.Diagnostics.EventLogPermission,System,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”类型的权限失败。
堆栈跟踪没有显示我的应用程序中的一行代码,它全部在框架中。 最后 5 行是: System.Security.CodeAccessSecurityEngine.Check(对象需求, StackCrawlMark&stackMark, Boolean isPermSet) +0 System.Security.CodeAccessPermission.Demand() +61 System.Diagnostics.EventLog..ctor(字符串 logName, 字符串 machineName, 字符串源) +125 系统.诊断.EventLog..ctor() +24 System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 Category, Byte[] rawData) +52
这个相同的应用程序在 XP SP2 上运行良好。我四处寻找,但找不到如何授予权限。我尝试将应用程序池作为 LocalSystem 和 ApplicationPoolIdentity 运行。
让它运行的最简单方法是什么?它是我的本地开发机器,我不在乎是否打开安全漏洞,只要我不必修改代码(即我需要解决方案是 INETMGR 更改或 web.config 或一些本地权限等) )。
谢谢!
I have an ASP.Net app .net 3.5 SP1, running in Win7 . During the login process, something within the ASP.Net login control is causing a write to the security log (this sounds acceptable to me) in the event log. The problem is that it seems the app doesn't have permission to do this. There error is:
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.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Diagnostics.EventLogPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The stack trace doesn't show a single line of code from my application, its all in the framework.
The last 5 lines are:
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +61
System.Diagnostics.EventLog..ctor(String logName, String machineName, String source) +125
System.Diagnostics.EventLog..ctor() +24
System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +52
This same app works fine on XP SP2. I've hunted around and can't find how to give permissions. I've tried running hte app pool as LocalSystem and ApplicationPoolIdentity.
Whats the easiest way to get this running? Its my local dev machine and I don't care if I open up security holes, as long as I don't have to modify code (ie I need the solution to be an INETMGR change or web.config or some local permissions, etc).
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此链接似乎正在讨论您遇到的问题。
我不确定 XP 与 win 7 上的默认 CAS(代码访问安全性)之间的差异,但是写入事件日志的程序集(以及所有调用程序集)必须具有 EventLogPermission。
您可以添加 AllowPartiallyTrustedCallers 属性或使用 强名称密钥。
This link appears to discuss the issue you are having.
I am not sure about the differences between the default CAS (code access security) on XP vs. win 7, however the assembly writing to the event log (and all calling assemblies) must have EventLogPermission.
You can add the AllowPartiallyTrustedCallers attribute or sign the assembly with a strong name key.
如果您要写入默认应用程序日志,则需要先向 LocalSystem 提供权限,然后才能在应用程序池中使用它。
打开RegistryEdit并右键单击
该应用程序,然后单击权限
如果用户 (LOCALSYSTEM) 不在列表中,则添加 和 允许完全控制
If you are writing to the default Application log you need to provide permisson to the LocalSystem before using it inside app pool.
Open RegistryEdit and goto
RightClick over the Applicatuion and click permissions
If the user(LOCALSYSTEM) is not present in the list then Add and Allow full Control