的iPlanet LDAP和C#PageResultRequestControl(iPlanet L

2019-09-02 09:09发布

我试图做上的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 ...
}

当我运行它,我得到的是美国例外“服务器不支持控制,控制是关键”的剪断前行。 快速谷歌搜索变成了什么。 是否支持的iPlanet分页? 如果是这样,我究竟做错了什么? 谢谢。

Answer 1:

所有LDAP V3兼容的目录中必须包含服务器支持的控件OID列表。 该列表可以通过发出一个空/空搜索根DN来获取目录服务器根DSE基本级别的搜索和阅读的多值来访问supportedControl -attribute。

对于分页搜索支持的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!");
    }
  }
}

我不认为的iPlanet支持分页但可能取决于你使用的版本。 孙造目录的新版本似乎支持分页。 你可能是最好关闭用我所描述的方法,检查您的服务器。



文章来源: iPlanet LDAP and C# PageResultRequestControl
标签: c# ldap