问题描述
我在寻找使用ADS目录搜索的findAll()方法现存登录(如下面的code)。它出现的findAll方法只返回1000个条目虽然有比这更条目。怎样的FindAll每次登录的()?
的IList<字符串> adslist =新的名单,其中,串>();
使用(的DirectoryEntry德=新的DirectoryEntry(LDAP://armlink.com,NULL,NULL,AuthenticationTypes.Secure))
使用(DirectorySearcher从DS =新DirectorySearcher从(德(对象类=用户),新的String [] {SAM帐户}))
的foreach(在ds.FindAll信息搜索结果SR())
{
字符串[] E = sr.Path.Split(新的String [] {LDAP://,OU =,,,DC =,.COM,/ CN =},StringSplitOptions .RemoveEmptyEntries);
ResultPropertyCollection PC = sr.Properties;
adslist.Add(E [0] +/+ PC [SAM帐户名] [0]的ToString());
//的Debug.WriteLine(adslist.Last());
}
这是由于服务器端的限制。从 DirectorySearcher.SizeLimit
文件:
和
基本上从这个,它看起来像除非有更改服务器端默认的方式,你将被限制在1000个条目。这有可能是指定一个每页
会让你获取一定数量的时间,用的总的大于1000 ...不知道。
顺便说一句,它看起来像你应该也有周围的 SearchResultCollection
A 使用
指令:
使用(SearchResultCollection结果= ds.FindAll())
{
的foreach(在结果信息搜索结果SR)
{
...
}
}
I am searching for existing logins using ADS Directory searcher findAll() method (as in following code). It appears the findall method returns only 1000 entries although there are more entries than that.How do I findAll() of every login ?
IList<string> adslist = new List<string>();
using (DirectoryEntry de = new DirectoryEntry("LDAP://armlink.com", null, null, AuthenticationTypes.Secure))
using (DirectorySearcher ds = new DirectorySearcher(de, "(objectclass=user)", new string[] { "samaccountname" }))
foreach (SearchResult sr in ds.FindAll())
{
string[] e = sr.Path.Split(new string[] { "LDAP://", "OU=", ",", "DC=", ".com", "/CN=" }, StringSplitOptions.RemoveEmptyEntries);
ResultPropertyCollection pc = sr.Properties;
adslist.Add(e[0] + "/" + pc["samaccountname"][0].ToString());
// Debug.WriteLine(adslist.Last());
}
This is due to a server-side limit. From the DirectorySearcher.SizeLimit
documentation:
And:
Basically from this, it looks like unless there's a way of changing the server-side default, you're going to be limited to 1000 entries. It's possible that specifying a PageSize
will let you fetch a certain number at a time, with a total greater than 1000... not sure.
By the way, it looks like you should also have a using
directive around the SearchResultCollection
:
using (SearchResultCollection results = ds.FindAll())
{
foreach (SearchResult sr in results)
{
...
}
}
这篇关于C#的Active Directory服务的findAll()只返回1000个条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!