如何使用C#获取域中的计算机名列表?
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); } }
来自http://msmvps.com/blogs/siva/archive/2008/01/25/enumerating-computers-in-a-domain.aspx