Get a list of computers in a domain using .Net

How to get a list of computer names in a domain using C #?

+4
source share
2 answers
using System.DirectoryServices; public void PrintComputersInDomain (string domainName) { DirectoryEntry de = new DirectoryEntry ("LDAP://" + domainName); de.Children.SchemaFilter.Add ("computer"); foreach (DirectoryEntry c in de.Children) { Console.WriteLine (c.Name); } } 

from http://msmvps.com/blogs/siva/archive/2008/01/25/enumerating-computers-in-a-domain.aspx

+8
source

If you are in a Windows domain, you can run an LDAP query on the directory to cancel the list of machine accounts

0
source

All Articles