iPlanet LDAP和C#PageResultRequestControl
我正在尝试在iPlanet LDAP上进行分页搜索。这是我的密码:iPlanet LDAP和C#PageResultRequestControl,c#,ldap,C#,Ldap,我正在尝试在iPlanet LDAP上进行分页搜索。这是我的密码: LdapConnection ldap = new LdapConnection("foo.bar.com:389"); ldap.AuthType = AuthType.Anonymous; ldap.SessionOptions.ProtocolVersion = 3; PageResultRequestControl prc = new PageResultRequestControl(1000); string[] pa
LdapConnection ldap = new LdapConnection("foo.bar.com:389");
ldap.AuthType = AuthType.Anonymous;
ldap.SessionOptions.ProtocolVersion = 3;
PageResultRequestControl prc = new PageResultRequestControl(1000);
string[] param = new string[] { "givenName" };
SearchRequest req = new SearchRequest("ou=people,dc=bar,dc=com", "(ou=MyDivision)", SearchScope.Subtree, param);
req.Controls.Add(prc);
while (true)
{
SearchResponse sr = (SearchResponse)ldap.SendRequest(req);
... snip ...
}
当我运行这个程序时,我得到一个异常,在snip之前的行中声明“服务器不支持该控件。该控件是关键的”。快速谷歌搜索什么也找不到。iPlanet支持分页吗?如果是,我做错了什么?谢谢。所有符合LDAP v3的目录都必须包含服务器支持的控件的OID列表。可以通过发出带有空/空搜索根DN的基本级别搜索以获取目录服务器根DSE并读取多值
supportedControl
-属性来访问该列表
分页搜索支持的OID为
下面是一段代码片段,让您开始学习:
LdapConnection lc = new LdapConnection("ldap.server.name");
// Reading the Root DSE can always be done anonymously, but the AuthType
// must be set to Anonymous when connecting to some directories:
lc.AuthType = AuthType.Anonymous;
using (lc)
{
// Issue a base level search request with a null search base:
SearchRequest sReq = new SearchRequest(
null,
"(objectClass=*)",
SearchScope.Base,
"supportedControl");
SearchResponse sRes = (SearchResponse)lc.SendRequest(sReq);
foreach (String supportedControlOID in
sRes.Entries[0].Attributes["supportedControl"].GetValues(typeof(String)))
{
Console.WriteLine(supportedControlOID);
if (supportedControlOID == "1.2.840.113556.1.4.319")
{
Console.WriteLine("PAGING SUPPORTED!");
}
}
}
我认为iPlanet不支持分页,但这可能取决于您使用的版本。Sun制造的目录的较新版本似乎支持分页。您最好使用我描述的方法检查服务器。没错,此服务器不支持分页。我将了解我们正在运行的版本以及是否有升级计划。谢谢