我正在尝试使用代码从Active Directory中获取所有用户:
PrincipalContext ad = new PrincipalContext(contextType, adserviceName, adContext, ContextOptions.SimpleBind, username, password);
UserPrincipal u = new UserPrincipal(ad) {Name = "*"};
PrincipalSearcher search = new PrincipalSearcher { QueryFilter = u };
foreach (var principal in search.FindAll())
{
//do something
}
但是它仅返回前1000行。如何在不使用DirectorySearcher的情况下检索所有用户。谢谢。
我认为如果不使用DirectorySearcher,您将无法做到这一点。
代码段-
// set the PageSize on the underlying DirectorySearcher to get all entries
((DirectorySearcher)search.GetUnderlyingSearcher()).PageSize = 1000;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句