Hi everyone,
I am trying to read off the "System" Event Log of a remote system.
I am getting the following error
"Cannot open log System on machine 10.50.212.129. Windows has not provided an error code"

when i try to access the Application log, my application encounters the same error
"Cannot open log Application on machine 10.50.212.129. Windows has not provided an error code"

The same code works fine for the Event Logs in my local system. The problem occurs when i am trying to access the logs of some remote system. After some initial digging on the internet i came to the conclusion that some permissions might be needed by the caller. i can see some C#.Net provided classes relating to permissions, but i cant find a gud MSDN link with an example to guide me.
Can someone please help me out...
i've used the code below.

EventLog eventLog = new EventLog("System","10.50.212.129");
foreach (EventLogEntry logEntry in eventLog.Entries)
{
if (logEntry.Source.Equals("smtpsvc") && logEntry.TimeGenerated > eventDate)
{
Console.WriteLine("Found One");
}
}

I get the error at the foreach statement.

Thanks in advance
-deathdarts

Recommended Answers

All 4 Replies

That's too logical to get error, if you didn't, for sure I was about to get another OS rather than Microsoft Windows, anyway, read in System.Security.Principal it helps you...

I AM an administrator in a Domain and i am trying to access the logs of a child domain.

The problem is you're assuming your authority is passed on, programattically it wont, you need to do that for it. Try your code out to start with locally.. before worrying about other machines.

Whatever :) You should specify username and password, I don't know how to add the flavor of impersonation to your application but I don't know did you reply after reading the namespace or you just don't need and insist on running your application correctly because you're the administrator??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.