我正在尝试在iPlanet LDAP上进行分页搜索.这是我的代码:
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 ...
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到一个异常,指出"服务器不支持控件.控件是关键的"在剪辑之前的行上.快速谷歌搜索没有任何结果.iPlanet是否支持分页?如果是这样,我做错了什么?谢谢.
Per*_*alt 10
所有符合LDAP v3的目录必须包含服务器支持的控件的OID列表.可以通过发出带有空/空搜索根DN的基本级别搜索来访问该列表,以获取目录服务器根DSE并读取多值 - supportedControl属性.
分页搜索支持的OID是1.2.840.113556.1.4.319.
这是一个代码片段,可以帮助您入门:
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!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不认为iPlanet支持分页,但这可能取决于您使用的版本.较新版本的Sun制作目录似乎支持分页.您可能最好使用我所描述的方法检查您的服务器.
| 归档时间: |
|
| 查看次数: |
3368 次 |
| 最近记录: |