Code
DirectoryEntry myDirectoryEntry = new DirectoryEntry("LDAP://" + d);
DirectorySearcher mySearcher = new DirectorySearcher(myDirectoryEntry);
mySearcher.Filter = "(&(objectCategory=person)(objectClass=user))";
mySearcher.SearchScope = SearchScope.Subtree;
SearchResultCollection searchResult = mySearcher.FindAll();
foreach (SearchResult result in searchResult)
{
ResultPropertyCollection props = result.Properties;
Console.WriteLine(props["name"][0].ToString());
}
域上面有很多个组织(OU),采用以上代码想显示所有用户,但是正式运行后发现只显示部分的用户,不知道为什么?