Solved

list all machine name and ip addresses in LAN using c#

Posted on 2009-04-08
6
9,967 Views
Last Modified: 2012-05-06
Hi

List of all machine name and ip addresses in LAN using c# Code
0
Comment
Question by:kapilgoyal
  • 3
6 Comments
 
LVL 3

Accepted Solution

by:
coagantus earned 84 total points
ID: 24104387
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24104393
0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 83 total points
ID: 24104400
it depends on if you have Active Directory (AD) set up. If you do, you can connect to AD using LDAP and query it from there (AD is basically just a database).

Here is an article that explains how to do this (it's actually pretty easy):
http://www.c-sharpcorner.com/UploadFile/jodonnell/ListAllComps07022005005654AM/ListAllComps.aspx
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24104402
0
 
LVL 9

Assisted Solution

by:Sreedhar Vengala
Sreedhar Vengala earned 83 total points
ID: 24104410
Something in VB.net

The following code sample shows how to get all IP address on a LAN network
Must have a reference to System.Net.DLL in your reference list.

Imports System.Net

Public Shared Function GetAllIP(Optional ByVal args As String() = Nothing) As Integer
'args in the signature is optional, without it
'the function will simply get the hostname
'of the local machine then go from there
Dim strHostName As New String("")
If args.Length = 0 Then
' Getting Ip address of local machine...
' First get the host name of local machine.
strHostName = DNS.GetHostName()
Console.WriteLine("Local Machine's Host Name: " + strHostName)
Else
strHostName = args(0)
End If

' Then using host name, get the IP address list..
Dim ipEntry As IPHostEntry = DNS.GetHostByName(strHostName)
Dim addr As IPAddress() = ipEntry.AddressList

Dim i As Integer = 0
While i < addr.Length
Console.WriteLine("IP Address {0}: {1} ", i, addr(i).ToString())
System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
End While
Return 0
End Function
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now