Access denied when reading system event log entries on ASP.NET web application hosted on IIS 8

ぐ巨炮叔叔 提交于 2020-02-05 04:03:55

问题


I have developed a quite simple ASP.NET web application that reads the system event logs entries.

When I am debugging or running it from VS 2017 (hosted in IIS Express) I am able to read the log entries without any issue.

Once I deploy/publish this asp.net web app on IIS 8 and try to read the system event log entries it doesn't work. If I check the event viewer I get something like this (translated from Spanish) :

System.InvalidOperationException: Unable to open the Application record on the computer Windows has not provided an error code. ---> System.ComponentModel.Win32Exception: Access Denied"

I have read other questions but are related to writing in the event log. I'm just interested in being able to read system event log entries. I guess it has something to do with permissions but I don't know which permissions I would have to set and to which user.

Here there are some parts of my code:

System.Diagnostics.EventLog  eventLog = new EventLog(LogName, machineName);
...
EventLogEntryCollection entries = eventLog.Entries; //This is where I get the Acces denied Exception.

Answer (workaround)

It may be not the proper way to solve it (for security issues), but as it is for the moment an internal application, I have made it work like this. That is, read the log Events from several remote machines through the use of impersonate on my web.config file

<system.web>   
   <identity impersonate="true" userName="SomeDomainUserWithRigtsToread" password="itsPwd"/>

回答1:


Note: It may be not the proper way to solve it (for security issues), but as it is for the moment an internal application, I have made it work, that is, read the log Events from several remote machines through the use of impersonate on my web.config file

<system.web>   
   <identity impersonate="true" userName="SomeDomainUserWithRigtsToread" password="itsPwd"/>


来源:https://stackoverflow.com/questions/51459272/access-denied-when-reading-system-event-log-entries-on-asp-net-web-application-h

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