我需要使用使用 .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 和 C# PageResultRequestControl
流量达到以下值后:
SearchResponse response = connection.SendRequest(request) as SearchResponse;
我收到一个目录操作异常,消息为"请求的属性不存在"。
通过在像 softerra 这样的 LDap 客户端上运行相同的查询,我得到了条目(一千个)和错误。
一些帮助将不胜感激。
我也有类似的问题。
使用分页搜索时,我得到了异常"The server does not support the control. The control is critical."
,当使用非分页搜索时,我收到了结果(至少只要过滤器限制最大数量)。
但是我发现,错误消息具有误导性 - 问题隐藏在身份验证中。
使用AuthType.Basic
(或AuthType.Anonymous
)我收到了错误。巴士一旦我切换到AuthType.Ntlm
它就工作了。
希望这有帮助...