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