C#.NET:检索域中文件夹中的计算机列表
如何检索域中文件夹中的计算机列表。 假设我有maydomain.dom作为我的域C#.NET:检索域中文件夹中的计算机列表,c#,.net-3.5,active-directory,directoryservices,C#,.net 3.5,Active Directory,Directoryservices,如何检索域中文件夹中的计算机列表。 假设我有maydomain.dom作为我的域 我有一个包含一些计算机的文件夹。下面的代码列出了您所在域和active directory中的计算机,这可能会对您有所帮助 //ActiveDirectorySearch1 //Displays all computer names in an Active Directory using System; using System.DirectoryServices; namespace ActiveDirect
我有一个包含一些计算机的文件夹。下面的代码列出了您所在域和active directory中的计算机,这可能会对您有所帮助
//ActiveDirectorySearch1
//Displays all computer names in an Active Directory
using System;
using System.DirectoryServices;
namespace ActiveDirectorySearch1
{
class Class1
{
static void Main (string[] args)
{
//Note : microsoft is the name of my domain for testing purposes.
DirectoryEntry entry = new DirectoryEntry(LDAP://microsoft);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=computer)");
Console.WriteLine("Listing of computers in the Active Directory");
Console.WriteLine("============================================"); foreach(SearchResult resEnt in mySearcher.FindAll())
{
Console.WriteLine(resEnt.GetDirectoryEntry().Name.ToString()); }
Console.WriteLine("=========== End of Listing =============");
}
}
}
这并不完全相同,但也许你可以使用与本文相同的原则:谢谢,但我需要知道如何在我的域中的特定文件夹中获取计算机