Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#.NET:检索域中文件夹中的计算机列表_C#_.net 3.5_Active Directory_Directoryservices - Fatal编程技术网

C#.NET:检索域中文件夹中的计算机列表

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

如何检索域中文件夹中的计算机列表。 假设我有maydomain.dom作为我的域
我有一个包含一些计算机的文件夹。

下面的代码列出了您所在域和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 ============="); 
}
}
}

这并不完全相同,但也许你可以使用与本文相同的原则:

谢谢,但我需要知道如何在我的域中的特定文件夹中获取计算机