C# 使用 .Net 获取域中的计算机列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/464983/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get list of computers in a domain using .Net
提问by user27052
How to get list of computer names in a domain using C# ?
如何使用 C# 获取域中的计算机名称列表?
回答by Hath
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
来自http://msmvps.com/blogs/siva/archive/2008/01/25/enumrating-computers-in-a-domain.aspx
回答by Student for Life
If you are on a windows domain, you can run an LDAP query against the directory to pull back a list of Machine Accounts
如果您在 Windows 域中,则可以对目录运行 LDAP 查询以拉回机器帐户列表