Get list of computers in a domain using .Net

大兔子大兔子 提交于 2020-01-01 11:48:24

问题


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


回答1:


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




回答2:


If you are on a windows domain, you can run an LDAP query against the directory to pull back a list of Machine Accounts



来源:https://stackoverflow.com/questions/464983/get-list-of-computers-in-a-domain-using-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!