Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.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# 如何在C中获取Active Directory的类列表#_C#_Active Directory_Ldap - Fatal编程技术网

C# 如何在C中获取Active Directory的类列表#

C# 如何在C中获取Active Directory的类列表#,c#,active-directory,ldap,C#,Active Directory,Ldap,我正在尝试获取Active Directory的类和属性列表 DirectoryEntry entry = new DirectoryEntry( "LDAP://CN=Schema,CN=Configuration,DC=addomain,DC=com", null, null, AuthenticationTypes.Secure); ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurren

我正在尝试获取Active Directory的类和属性列表

DirectoryEntry entry = new DirectoryEntry(
        "LDAP://CN=Schema,CN=Configuration,DC=addomain,DC=com",
        null, null, AuthenticationTypes.Secure);

ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema();
ActiveDirectorySchemaClass User = schema.FindClass("account");

foreach (ActiveDirectorySchemaProperty property in User.GetAllProperties())
{
    Console.WriteLine("{0}", property.Name);
}
这将返回指定类的所有属性。如何获取Active Directory中存在的所有类

如何获取Active Directory中存在的所有类

您需要修改已使用的相同代码。您需要找到该模式的所有类,如下所示。它将返回一个只读集合,其中包含
ActiveDirectorySchemaClass
对象,您需要读取这些对象的各个项

DirectoryEntry entry = new DirectoryEntry(
        "LDAP://CN=Schema,CN=Configuration,DC=addomain,DC=com",
        null, null, AuthenticationTypes.Secure);

ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema();

// below code retrieves all Active Directory Domain Services classes in the schema.
ReadOnlyActiveDirectorySchemaClassCollection collection = schema.FindAllClasses();

// Now you can iterate over the collection Items.
foreach (ActiveDirectorySchemaClass schemaClass in collection)
   {
       foreach (ActiveDirectorySchemaProperty property in schemaClass.GetAllProperties())
          {
              Console.WriteLine("{0}", property.Name);
          }
   }
有关更多详细信息,请参阅MSDN