473,324 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Access to EventLog on remote computer

Hello!
How I can gain access to event log on remote machine?
Computers are in the same network but they are not in domain, they are
only in the same workgroup.
I've tried MachineName property in EventLog class but I get
exception.
I know administrator password on remote computer but how can I say
EventLog class "log in to remote computer with this username and
password"?

I code under .NET Framework 1.1

Below sample code and the exception I get

Thanks in advance for help
Bartek

// some code
try
{
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.MachineName = "lasulaptop";
log.Log = "Application";

int test = log.Entries.Count;
}
catch (UnauthorizedAccessException ex)
{
throw;
}

// some code
This is exception I get

System.UnauthorizedAccessException was caught
Message="Attempted to perform an unauthorized operation."
Source="mscorlib"
StackTrace:
at Microsoft.Win32.RegistryKey.Win32ErrorStatic(Int32 errorCode,
String str)
at Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Regi stryHive
hKey, String machineName)
at System.Diagnostics.EventLog.GetEventLogRegKey(Stri ng machine,
Boolean writable)
at System.Diagnostics.EventLog.Exists(String logName, String
machineName)
at System.Diagnostics.EventLog.OpenForRead(String
currentMachineName)
at System.Diagnostics.EventLog.get_EntryCount()
at System.Diagnostics.EventLogEntryCollection.get_Cou nt()
at

May 22 '06 #1
4 14299
Hello, ba*******************@gmail.com!

Are you able to connect to remote Event Log via mmc snap-in?

You can try to impersonate with the remote user and then access remote event log
To impersonate you will LogonUser and other win32 api:

( http://www.thecodeproject.com/csharp...rsonation1.asp )
( http://www.pinvoke.net/default.aspx/advapi32.LogonUser )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
May 23 '06 #2
Acctualy no, I can't access over this snapin.
I also get the same error 'access denied'.
I've tried imersonate user but I get the same exception.
I disabled firewal on remote host but it also did not help.

Do you have any idea what I'm dining wrong?

Regards,
Bartek

May 23 '06 #3
Try to map the current username/password to the remote server. From a
quick pick at Reflector it does not seem to pass authentication tokens
while quering the remote eventlog.

Also check in the remote system if Remote Registry service is running
and the user has access to SYSTEM\CurrentControlSet\Services\EventLog
key registry.

Regards,
Tasos

May 23 '06 #4
I found some solution. I can gain access to remote event log over
Windows Management Instrumentation.
I don't know if it is the best way to go but at least it works.

Thanks for help.

Regards
Bartek

May 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe | last post by:
I am trying to read the EventLog of different servers on the network. If I run the script in a command line, it works well. But when I try to put the script into the Web server (IIS in Windows...
1
by: JV | last post by:
It's great that the CLR gives us this cool EventLog object for managing event logs. And they even give you this cool property "MachineName" to allow you to deal with event logs on a remote...
1
by: Morris | last post by:
I create a custom log and write new entries to this log fine. However, at random time, I got error message error message like this "The description for Event ID ( 0 ) in Source ( MyCustomLog)...
2
by: Next | last post by:
Hello all, I have a windows service that was suppose to write some events into its own EventLog. I created the EventLog using the component on VS 2003 toolbar Added an installer for it. Set...
3
by: bas jaburg | last post by:
Hi, I am using the Microsoft Application BuildingBolock (Freudian slip, hahaha) Exception Management and am using a CustomPublisher. This goes fine and it write's stuff the Windows EventLog. ...
1
by: Mark | last post by:
Can I access Event log of a remote computer from an aspx page (Server side) Thanks
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
0
by: sk.rasheedfarhan | last post by:
Hi all, According to my project requirement I have to write the NT Event information of SQL Server into EventLog viewer. For more clear I want to write the following information into...
0
by: sanmdar | last post by:
I am currently facing a problem in the implementation of event logging in C++. The requirement is that one of the service created by us should log the events and the supporting information. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.