c# - 分页 LDap 搜索失败,错误代码为 "The requested attribute does not exists"

标签 c# ldap

我需要使用使用 .NET/C# 实现的 Ldap 搜索来获取“epersonstatus=REMOVE”的所有员工的“员工编号”,例如:

var connection = new LdapConnection("foo.bar.com:389");

connection.AuthType = AuthType.Anonymous;
connection.SessionOptions.ProtocolVersion = 3;
connection.Bind();

var request = new SearchRequest(
                 "dc=root,dc=com",
                 "(epersonstatus=REMOVE)", 
                 SearchScope.Subtree,
                 new string[] { "employeenumber" }); 

由于有数千个条目,我正在使用此处建议的分页请求: http://dunnry.com/blog/PagingInSystemDirectoryServicesProtocols.aspx

我还检查了服务器是否支持此处建议的分页请求: iPlanet LDAP and C# PageResultRequestControl

一旦流量达到:

SearchResponse response = connection.SendRequest(request) as SearchResponse;

我收到一个 DirectoryOperationException,其中包含消息“请求的属性不存在”。

通过在像 softerra 这样的 LDAP 客户端上运行相同的查询,我得到了条目(一千)并且 错误。

如果有一些帮助,我们将不胜感激。

最佳答案

我也遇到了类似的问题。

使用分页搜索时,出现异常 "The server does not support the control. The control is critical." ,当使用非分页搜索时,我收到了结果(至少只要过滤器限制了最大数量)。

但是我发现,错误消息具有误导性 - 问题隐藏在身份验证中。

使用AuthType.Basic (或 AuthType.Anonymous )我收到错误。我一转公交AuthType.Ntlm它起作用了。

希望这有帮助...

关于c# - 分页 LDap 搜索失败,错误代码为 "The requested attribute does not exists",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11842329/

相关文章:

c# - WPF 新增功能 - 更新代码中的 TextBlock 导致 NullReferenceException

尽管服务正在运行,但 Docker 容器会立即退出

logging - SonarQube LDAP 1.4 -> 调试日志记录

java - Spring Boot 应用程序中的 LDAP 身份验证

database - LDAP 数据库与 SQL 或 MySql 数据库有何不同

c# - 将 Active Directory 属性设置为 "not set"的 .Net 代码

c# - 参数化查询中缺少必需参数?

c# - 如何编写一个我可以同时使用字符串和整数的扩展方法?

c# - 通过反射仅获取当前类(class)成员

c# - 测试某个值是否为空