是否有任何直接的方法让所有的OU进入一个活动目录?我已经尝试了以下代码,并且我得到了Com异常(无效操作)
ouSearch.FindAll()我的代码如下所示。
public static List<string> GetAllOus(string ldapServer, string ldapUserName, string ldapPassWord)
{
List<string> orgUnits = new List<string>();
string defaultNamingContext;
DirectoryEntry rootDSE = new DirectoryEntry(ldapServer + "/dc=server-dc,dc=com", ldapUserName, ldapPassWord, AuthenticationTypes.Anonymous);
//defaultNamingContext = rootDSE.Properties["defaultNamingContext"].Value.ToString();
//DirectoryEntry defaultentry = new DirectoryEntry("LDAP://" + defaultNamingContext);
DirectorySearcher ouSearch = new DirectorySearcher(rootDSE,
"(objectClass=organizational-Unit)",
null, SearchScope.Subtree);
foreach (SearchResult resEnt in ouSearch.FindAll())
{
string OUName = resEnt.GetDirectoryEntry().Name;
orgUnits.Add(OUName);
}
return orgUnits;
}请帮我解决这个问题。
提前感谢
发布于 2013-08-05 07:24:21
使用(objectClass=organizationalUnit)代替(objectClass=organizational)
https://stackoverflow.com/questions/16810382
复制相似问题