代码之家  ›  专栏  ›  技术社区  ›  ristonj

iPlanet LDAP和C pageResultRequestControl

  •  4
  • ristonj  · 技术社区  · 16 年前

    我正在尝试在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是否支持分页?如果是,我做错了什么?谢谢。

    1 回复  |  直到 14 年前
        1
  •  10
  •   Per Noalt    16 年前

    所有与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!");
        }
      }
    }
    

    我不认为iPlanet支持分页,但这可能取决于您使用的版本。新版本的sun-made目录似乎支持分页。您最好使用我描述的方法检查服务器。