Don't PInvoke NetXXXX API's, use DirectoryServices namespace instead.
Try this:
using System;
using System.DirectoryServices;
//************************************************** **************************/
class Tester {
public static void Main() {
String unl = new string(('_'),60);
DirectoryEntry container;
using( container = new DirectoryEntry("WinNT://celeb", "celeb\\administrator", "kevin", AuthenticationTypes.ServerBind))
{
DirectoryEntries computers = container.Children;
computers.SchemaFilter.Add("Computer");
foreach (DirectoryEntry computer in computers) {
try
{
Console.WriteLine("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.WriteLine("Name" + ":\t" + (computer.Properties["Name"])[0].ToString());
}
catch(Exception e)
{
// "The network path was not found." will be thrown when a member is down or unreacheable.
Console.WriteLine(e.Message );
}
}
}
}
}
Willy.
"Jonny" <jo*****************@hotmail.com> 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