Ryan Rodemoyer
Ryan Rodemoyer

Reputation: 5692

Query for computers on a domain that are online

Where I work we use a piece of software called Dameware to remotely manage computers on our domain. Through Dameware we are able to get a list of all of the computers that are online and currently connected to the domain.

We are in the process of rolling out new desktop management software that does not provide this feature to us. We need to know the name of a computer when we want to connect to it.

I know how to get a list of the computers that belong to the domain but that also returns computers that may or may not be online. How do I return a list of computers that are currently connected (ie. they have an active network connection) to the domain? I thought about returning a list of computers that belong to the domain and then pinging each one but I think that would be slow and a complete waste of resources.

I would prefer a .NET solution but VB script will work as well. I may end up building a GUI for this that I would distribute to members of our IT team.

Upvotes: 1

Views: 1053

Answers (3)

Manish Sinha
Manish Sinha

Reputation: 2112

Well Ping can actually work.

I am working on scapy library which is a python library to create TCP/IP packets. I used to ping a subnet like 192.168.1.0/24. I tried many kinds of pings - ARP, ICMP, TCP.UDP. The results were shocking --

  • TCP and UDP ping take lifelong to return all the answers
  • ICMP also takes less time, but still I had to wait for 40s or more
  • ARP pings were the best. It took not more than 2-3 secs to return back the answer. You can try this and tell me what are your experiences

You should use the Ping class of .NET for doing so.

You should even check this question on Stack Overflow


ARP Library for .NET

As of now I don't have any idea if .NET gives an abstraction of ARP, but it can be used via iphlpapi.dll

This DLL has a function named SendARP having a signature

int SendARP( int DestIP, int SrcIP, byte[] pMacAddr, ref uint PhyAddrLen );

You should check this page for more example and also read about iphlpapi.dll

Upvotes: 1

Shay Erlichmen
Shay Erlichmen

Reputation: 31928

How do you find all the computers using NetServerEnum?
Anyway I suggest that you don't bother with finding which machine is online, since that could change by the time the user/application will try to act on that machine.

Upvotes: 0

Erich Mirabal
Erich Mirabal

Reputation: 10038

Can you install on each computer a monitor app that sends a heartbeat to a central DB? Then, you could query from the DB, keep track of more stats, etc by having a little app on each computer.

This way, you distribute the cost of keeping status from your monitoring tool to each machine, get the ability to keep history (which machines were down at what time, etc), and simplify your monitoring tool to just run a quick query on the DB instead of doing pings on each machine

Also, I've had problems with some machines not responding to pings depending on their firewall settings (thank you Windows XP with Firewall turned on).

Finally, the good thing about this is that you can also replace your UI to use whatever you wanted (C#, web page, etc...).

Upvotes: 0

Related Questions