授予我的代码事件日志权限
您好,我正在尝试授予我的应用程序对事件日志的完全访问权限,因此我已将这段代码放入其中,我基本上只是想知道之前使用/见过此内容的人是否可以验证我所做的事情是否正确,或者我是缺少任何步骤吗?
string thisMachineName = System.Net.Dns.GetHostName();
EventLogPermission eventReaderPermission = new EventLogPermission(EventLogPermissionAccess.Administer, thisMachineName);
eventReaderPermission.Demand();
Hi I am trying to grant my application full access to the event logs, so I have put this code in, and I am basicallyjust wondering if somebody who has used/seen this before can verify that what I have done is correct, or am I missing any steps?
string thisMachineName = System.Net.Dns.GetHostName();
EventLogPermission eventReaderPermission = new EventLogPermission(EventLogPermissionAccess.Administer, thisMachineName);
eventReaderPermission.Demand();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Demand() 方法将抛出安全错误如果您的应用程序尚不具有对事件日志的管理级别访问权限,则会在运行时出现异常。它不会授予许可。
恐怕授予访问权限比单个方法调用要困难得多。您应该阅读如何管理代码访问安全性。
The Demand() method will throw a security exception at run time if your application does not already have Administer-level access to the event log. It will not grant permission.
Granting access is much more difficult than a single method call, I'm afraid. You should read-up on how to manage code access security.