0
我在我的應用程序中使用此LDAP class。 我在我的本地主機上有Apache DS,它工作正常。在Java中的LDAP搜索APP
在我的應用程序,我成功地連接到LDAP服務器:
conn.connect("localhost", 10389);
conn.bind(LDAPConnection.LDAP_V3, "uid=admin,ou=system","secret".getBytes("UTF8"));
然後我試着來搜索LDAP目錄中的一些數據:
attrList = new String[]{"dn", "cn", "mail"};
sFilter = "([email protected])";
LDAPSearchConstraints cons = new LDAPSearchConstraints();
cons.setDereference(LDAPSearchConstraints.DEREF_ALWAYS);
LDAPSearchResults searchResults = conn.search("uid=admin,ou=system", LDAPConnection.SCOPE_SUB, sFilter, attrList, false,cons);
並且在SearchResult所沒有結果。那麼你能幫我嗎? 但是當我在Apache DS Studio中使用相同參數進行搜索時,我可以看到一些結果。 請檢查這screenshot。
在屏幕截圖中,過濾器與請求的屬性列表不同。這是由設計嗎? –
它只是我愚蠢的錯誤。截圖現在已修復。 –
「mail」屬性從屬於'uid = admin,ou = system'的對象嗎?將基礎對象設置爲該值時,LDAP目錄服務器將僅將基礎對象處於或低於基礎對象的對象視爲候選項,以在搜索結果中返回到LDAP客戶端。 –