我试图查询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服务器上工作。现在,containerDistinguishedName是空的,但是可以用值填充以进一步限制搜索筛选器。
发布于 2013-12-08 15:18:37
从这个角度来看,一个空的containerDistinguishedName引用了Root,但是一个subtree作用域的搜索仍然可以工作,假设连接的授权状态允许拖网搜索DIT (只有在搜索唯一的搜索结果是base时才返回Root )。尝试使用为containerDistinguishedName“高于”DIT的基本对象,类似于dc=example,dc=com。
另请参阅
https://stackoverflow.com/questions/20220651
复制相似问题