1
我正在尝试使用LDAP来验证用户,但我遇到了LDAP问题。可分辨名称包含无效语法错误
这是我的代码:
string hostOrDomainName = "MrHand-PC";
string targetOu = "cn=Huy Pham,ou=people,dc=example,dc=com";
// create a search filter to find all objects
string ldapSearchFilter = "uid=pdhuy";
// establish a connection to the directory
LdapConnection connection = new LdapConnection(hostOrDomainName);
Console.WriteLine("\r\nPerforming a simple search ...");
SearchRequest searchRequest = new SearchRequest(targetOu, ldapSearchFilter,
System.DirectoryServices.Protocols.SearchScope.OneLevel, null);
// cast the returned directory response as a SearchResponse object
SearchResponse searchResponse =
(SearchResponse)connection.SendRequest(searchRequest);
最后一行抛出异常:The distinguished name contains invalid syntax.
谁能帮我解决这个问题?
我不认为'MrHand-PC'是LdapConnection的一个有效LDAP路径 - 尝试使用类似于'LDAP:// MrHand-PC/dc = YourCompany,dc = com' - **有效** LDAP路径 – 2010-06-02 17:03:14
感谢您的快速回复,我使用路径:LDAP:// localhost:389/dc = example,dc = com与LDAP浏览器,它的工作(我安装OpenLDAP在我的本地PC)。 Active Directory一切正常,您是否可以解释我的问题? – handle0088 2010-06-03 04:30:58