我正在尝试查询 LDAP 服务器以查找 LDAP 用户并将其导入到我的系统中。但是,当我尝试执行此操作时,请求会抛出DirectoryOperationException
,说The object does not exist
.
ldapConnection.AuthType = AuthType.Negotiate;
if (ldapDomain.UseEncryption)
{
ldapConnection.SessionOptions.SecureSocketLayer = true;
ldapConnection.SessionOptions.StartTransportLayerSecurity(null);
}
var credentials = new NetworkCredential(loginName, password, ldapDomain.Name);
ldapConnection.Bind(credentials);
var filter = String.Format("(&(objectCategory=person)(objectClass=user)(anr={0})(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))", loginName);
var request = new SearchRequest(containerDistinguishedName, filter, SearchScope.Subtree);
var response = ldapConnection.SendRequest(request) as SearchResponse;
var entry = response.Entries[0];
我只需使用 Microsoft/Windows LDAP 服务器即可。现在,containerDistinguishedName
为空,但可以填充值以进一步限制搜索过滤器。
从这一点来看,空无一物containerDistinguishedName
指根 DSE,但是subtree
范围搜索应该仍然有效,假设连接的授权状态允许拖网 DIT(如果搜索唯一,则仅在搜索结果中返回根 DSE)base
)。尝试使用“顶部”DIT 的基础对象containerDistinguishedName
, 就像是dc=example,dc=com
.
see also
- LDAP:搜索最佳实践 http://www.ldapguru.info/ldap/ldap-search-best-practices.html
- LDAP:编程实践 http://www.ldapguru.info/ldap/ldap-programming-practices.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)