发布网友 发布时间:12分钟前
共3个回答
热心网友 时间:17分钟前
如果你是找用户应该是 :
searcher.Filter ="(objectClass=user)";
然后遍历 searcher.FindAll()
foreach (SearchResult result in searcher.FindAll())
{
///
}
热心网友 时间:11分钟前
/// <summary>
/// 根据公共名称获取用户对象
/// </summary>
/// <param name="commonName">用户名称</param>
/// <returns>DirectoryEntry</returns>
public static DirectoryEntry GetDirectoryEntry(string commonName)
{
DirectoryEntry de = GetObjectByAdmin();
DirectorySearcher deSearch = new DirectorySearcher(de);
deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(cn=" + commonName + "))";
deSearch.SearchScope = SearchScope.Subtree;
try
{
SearchResult result = deSearch.FindOne();
de = new DirectoryEntry(result.Path);
return de;
}
catch
{
return null;
}
热心网友 时间:10分钟前
风光好