Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-04-08
6
Medium Priority
?
12,538 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 336 total points
ID: 24104387
0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 332 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 332 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

963 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