0
我有以下LDAP方案:春LDAP動態基礎DN
每個子樹包含組織單位隊。我想從特定的子樹中找到所有團隊。要做到這一點,我使用LdapTemplate
類和findAll()
方法。
ldapTemplate.findAll(Team.class);
當我設置在LdapContextSource
基地dc=global,dc=id,dc=pl
從全球樹返回我的團隊。當我將基數改爲dc=id,dc=pl
時,它會返回來自所有子樹的團隊。
問題是我想使用動態基礎,從特定的子樹中查找團隊。我嘗試了多種方法來實現這一點,但沒有一個給我的結果。
方法1:找到
Name nameBase = LdapUtils.newLdapName("dc=global");
return ldapTemplate.find(query().base(nameBase).where("ou").is("team"), Team.class);
回報空單
方法2:的findAll
Name nameBase = LdapUtils.newLdapName("dc=global");
SearchControls searchControls = new SearchControls();
return ldapTemplate.findAll(nameBase, searchControls, Team.class);
回報空單
起初,它看起來像正常工作,因爲當我改變子樹名其中一些不存在的,我得到javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]
任何想法,爲什麼我得到這個代碼正確的結果:
LdapContextSource contextSource = new LdapContextSource();
contextSource.setBase("dc=global,dc=id,dc=pl");
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
return ldapTemplate.findAll(Team.class);
而空從這一個列表:
LdapContextSource contextSource = new LdapContextSource();
contextSource.setBase("dc=id,dc=pl");
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
Name nameBase = LdapUtils.newLdapName("dc=global");
SearchControls searchControls = new SearchControls();
return ldapTemplate.findAll(nameBase, searchControls, Team.class);
我使用Spring-LDAP的核心2.0.3