65.9K
CodeProject is changing. Read more.
Home

Simple Network Scanner

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.83/5 (10 votes)

Apr 24, 2008

CPOL

1 min read

viewsIcon

78058

downloadIcon

9952

Scans given workgroup for computer names, with IP and MAC addresses

Introduction

This simple network scanner scans the given work group/domain for computers in Directory Services. It also displays their IP and MAC addresses. You will also find code to get IP address against computer name and to get MAC address against IP address.

Background

It all started when I was developing a Backup System, which was supposed to list all the computers in a network and later, the user can select any one or all computers and can record backup.

Using the Code

This is a very easy to use application. Just download this application and type your work group or domain name and press Scan button.

In the first step, this system will get all directory entries in Directory Services (to use directory services in your project, you must add a reference to System.DirectoryServices namespace) using the following code:

DirectoryEntry DomainEntry = new 
    DirectoryEntry("WinNT://" + txtWorkGroupName.Text + ""); 
DomainEntry.Children.SchemaFilter.Add("Computer");

Next it will iterate for all computers/machines through DomainEntry; and it will call getIPByName() function to get the IP address. getIPByName() function uses System.Net.DNS static class to get the IP address.

Finally, there is a function getMACAddress(IPAddress ipAddress). In this SendARP() function call has been made to get the MAC address against IP. SendARP() is part of iphlpapi.dll.

Points of Interest

You can get a list of computers in your network with their IP and MAC addresses, which means it is a three in one package.

History

  • 24th April, 2008: Initial post