c# - iPlanet LDAP 和 C# PageResultRequestControl

标签 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[] 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 是否支持分页?如果是这样,我做错了什么?谢谢。

最佳答案

所有 LDAP v3 兼容目录必须包含服务器支持的控件的 OID 列表。可以通过使用 null/空搜索根 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 制作的目录似乎支持分页。您可能最好使用我描述的方法检查您的服务器。

关于c# - iPlanet LDAP 和 C# PageResultRequestControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1646518/

相关文章:

c++ - 如何从 C++ 使用 LDAP 连接到 Active Directory?

c# - 使用 System.DirectoryService 连接到 OpenDS

javascript - 向用户呈现多条确认消息的最佳方式

c# - 为什么我的 WSDL 仍然显示具有 http 位置值的基本 http 绑定(bind)?

java - Spring LDAP : error code 4 - Sizelimit Exceeded - when setting countLimit to 1

java - LDAP 类型的数据源 url 是什么

c# - 将只有几列的数据复制到另一个数据表中

c# - 我的 StreamReader 只从我的 4 行文本文件中读取第二行和第四行

c# - 在自定义方法中为数组中的元素分配最小值 (array.Min())

ssl - 是否可以在 WAS7 和 ActiveDirectory 之间的 LDAP 上配置两种方式的 ssl