2

I have a requirement where I need to just open an Event Viewer to the internal users from an internal webpage. I have a link "Evetn Viewer" and a dropdown "Servers", when user select a server and click the link, I want to open the windows event viewer. How to do this?

Sri Reddy
  • 6,832
  • 20
  • 70
  • 112

2 Answers2

2
    EventLogSession session = new EventLogSession(
        "RemoteComputerName",// Remote Computer
        "Domain",// Domain
        "Username",// Username
        pw,
        SessionAuthentication.Default);

Read more here How to manage event logs using Visual C# .NET

Stefan P.
  • 9,489
  • 6
  • 29
  • 43
  • Stefan, I tried the code from the link you provided and it works for my local event viewer but if I want to access an event viewer of a server I get Unauthorized error. I used: using (EventLog ev = new EventLog(logType, machinename)). Since web based application is trying to access the event log (I do only read), not sure how do I write the code to authenticate and authorixe the user to access the log? Appreciate if you can respond. – Sri Reddy Apr 06 '11 at 20:31
  • The computer that hosts the web app should be in the same Domain as the server. In active directory you should create a user with EnventLog read rights. Then you should use the EventLogSession as showed in the example and pass the credentials for the AD user. – Stefan P. Apr 07 '11 at 10:02
  • Thanks Stefan, any link that gives the steps with an example? – Sri Reddy Apr 07 '11 at 12:31
1

The only way to open the Event Viewer within Windows would be with an ActiveX control of some type. Event Viewer can be started with the server name as an argument: eventvwr myserver.

Here's some basic guidance on how to create these: http://www.c-sharpcorner.com/uploadfile/dsandor/activexinnet11102005040748am/activexinnet.aspx

Otherwise you'll be restricted to loading the events server-side and returning them in the markup (make sure you restrict the results - event logs can get pretty big!)

David Neale
  • 16,498
  • 6
  • 59
  • 85