Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get PC Names on the Network

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
I am trying to get a listin of all the PC names on the network and add them to a listbox. The code builds fine, but it does not work.

The error I get is:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in system.directoryservices.dll

Additional information: The server is not operational

I am running Windows XP. Any help would be greatly appreciated!


private void Form1_Load(object sender, System.EventArgs e)
{
DirectoryEntry entry = new DirectoryEntry("LDAP://microsoft");
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=computer)");

foreach (SearchResult d in mySearcher.FindAll())
{
this.lstPCNames.Items.Add(d.GetDirectoryEntry().Name.ToString());
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top