我需要使用使用 .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/