Don't PInvoke NetXXXX API's, use DirectoryServic es namespace instead.
Try this:
using System;
using System.Director yServices;
//*************** *************** *************** *************** *************** */
class Tester {
public static void Main() {
String unl = new string(('_'),60 );
DirectoryEntry container;
using( container = new DirectoryEntry( "WinNT://celeb", "celeb\\adminis trator", "kevin", AuthenticationT ypes.ServerBind ))
{
DirectoryEntrie s computers = container.Child ren;
computers.Schem aFilter.Add("Co mputer");
foreach (DirectoryEntry computer in computers) {
try
{
Console.WriteLi ne("domain member path: " + computer.Path);
// connect with the member to retrieve its name
// this can be very time consuming in a large domain, especially when some PC's are off-line
Console.WriteLi ne("Name" + ":\t" + (computer.Prope rties["Name"])[0].ToString());
}
catch(Exception e)
{
// "The network path was not found." will be thrown when a member is down or unreacheable.
Console.WriteLi ne(e.Message );
}
}
}
}
}
Willy.
"Jonny" <jo************ *****@hotmail.c om> wrote in message news:06******** *************** *****@phx.gbl.. .
I'm sure this is easy and i'll kick myself for it.
How would i go about listing all the machines on a domain?
I want to display them in a list box.
Thanks
/Jonny