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