我正在尝试使用 读取 Active Directory 架构数据DirectorySearcher
,如下所示:
DirectoryEntry entry = new DirectoryEntry("LDAP://********/CN=Schema,*****");
var filter = "(&(objectCategory=attributeSchema))";
var directorySearcher = new DirectorySearcher(entry, filter);
var searchResult = directorySearcher.FindAll();
DirectoryEntry schemaTest2 = entry.SchemaEntry;
// error on this line:
// "The directory cannot report the number of properties."
foreach (var prop in schemaTest2.Properties.PropertyNames)
{
string propName = prop.ToString();
}
有谁知道为什么会发生此错误?或者您对如何使用阅读 AD 架构有什么建议DirectorySerarcher
?
注意:我不能使用
ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema();
因为我面临着其他一些问题。
任何建议将不胜感激!
谢谢。