How to get the names of the availalbe computers on your LAN/Workgr

F

Fernik

Hi, I need to get a list of the computers in my WorkGroup LAN, with its names
in a similar way you get the available Drives from a PC with
DriveInfo.GetDrives(). Is there a managed class that provide this, if not,
coudl you provide me some guiadance with unmanaged APIs or wrappers.
 
M

Michael Nemtsev [MVP]

Hello Fernik,

use NetServerEnum WinAPI method
The sample and description how to do in from managed code is there http://www.codeproject.com/KB/IP/ListNetworkComputers.aspx

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


F> Hi, I need to get a list of the computers in my WorkGroup LAN, with
F> its names in a similar way you get the available Drives from a PC
F> with DriveInfo.GetDrives(). Is there a managed class that provide
F> this, if not, coudl you provide me some guiadance with unmanaged APIs
F> or wrappers.
F>
 
S

Steven Cheng[MSFT]

Hi Fernik,

As for looping network resources in local network, there are several means
such as RAW network API, wmi or ADSI:

here are some web threads discussing on this, you can have look to see
whether they help some:

API approach:

#list of computers on local network
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=29925

#Using Network Functions in Visual C#.NET (Part II - Group Functions)
http://www.csharphelp.com/archives2/archive440.html


ADSI approach:

#Inventory of Domain Users and Computers Using ADSI
http://www.serverwatch.com/tutorials/article.php/1476791

#List of computers on local network
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=29925


WMI:

http://www.siccolo.com/Articles/CodeProject/Build_Local_Network_Browser/Buil
d_Local_Network_Browser.html

http://www.activexperts.com/activmonitor/windowsmanagement/wmi/samples/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.




--------------------
 
F

Fernik

Hey Steven,

Thanks for your resourceful post, I did managed to build my own
NetworkBrowser class that enumerates the Domain computers and its shares,
however I have another question. Some shares require credentials in order to
access/enumerate them and they throw an UnauthorizedExcepcion, is there any
way to invoke the OS dialog that Windows Explorer displays when it need to
request credentials for a network resource, if not which APIs
managed/unmanaged are available to perform that impersonation.

--
Fernik
http://www.fernik.com.ar


Steven Cheng said:
Hi Fernik,

As for looping network resources in local network, there are several means
such as RAW network API, wmi or ADSI:

here are some web threads discussing on this, you can have look to see
whether they help some:

API approach:

#list of computers on local network
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=29925

#Using Network Functions in Visual C#.NET (Part II - Group Functions)
http://www.csharphelp.com/archives2/archive440.html


ADSI approach:

#Inventory of Domain Users and Computers Using ADSI
http://www.serverwatch.com/tutorials/article.php/1476791

#List of computers on local network
http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=29925


WMI:

http://www.siccolo.com/Articles/CodeProject/Build_Local_Network_Browser/Buil
d_Local_Network_Browser.html

http://www.activexperts.com/activmonitor/windowsmanagement/wmi/samples/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.




--------------------
 
S

Steven Cheng[MSFT]

Hi Fernik,

As for the protected network share, I'm afraid popup the login dialog
(interactively) is not quite doable here. The reasonable way is to run your
application(at least the thread) under a proper domain account(the
impersonate as you mentioned). Here is a kb article mentioned how to call
API to enstablish a certain account's logon session and impersonate in
.NET( the article is for ASP.NET, but the code in it also fits deskop
application):

#How to implement impersonation in an ASP.NET application
http://support.microsoft.com/kb/306158/en-us

Hope this helps also.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?RmVybmlr?= <[email protected]>
References: <[email protected]>
Subject: RE: How to get the names of the availalbe computers on your LAN/Wo
Date: Fri, 4 Jan 2008 16:18:01 -0800

Hey Steven,

Thanks for your resourceful post, I did managed to build my own
NetworkBrowser class that enumerates the Domain computers and its shares,
however I have another question. Some shares require credentials in order to
access/enumerate them and they throw an UnauthorizedExcepcion, is there any
way to invoke the OS dialog that Windows Explorer displays when it need to
request credentials for a network resource, if not which APIs
managed/unmanaged are available to perform that impersonation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top