Spring LdapTemplate未初始化-错误

时间:2020-08-03 14:52:15

标签: spring spring-boot spring-security spring-ldap

感谢您的帮助。

我声明了我的类变量:

public class HttpLdapDao {
   private LdapTemplate ldapResetEnveloppe;

我在函数中初始化此变量:

public boolean testADMCredential(Credential credential, Environment env) {
    ...
    LdapContextSource newContext = new LdapContextSource();

    newContext.setBase(baseDn);
    newContext.setUserDn(userDn);
    newContext.setPassword(password);
    newContext.setUrl(url);
    newContext.afterPropertiesSet();

    ldapResetEnveloppe = new LdapTemplate(newContext);
    ...
}

当我想在另一个函数中使用变量ldapResetEnveloppe时:

public boolean updateLdapUser(Enveloppe enveloppe, Environment env) {
       System.out.println(ldapResetEnveloppe.list(baseDn));
       ... 
 }

我收到此错误消息:

org.springframework.ldap.NameNotFoundException: [LDAP: error code 32 - No Such Object]; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'ou=people,dc=****,dc=****'

我要先调用第一个函数。

你能解释一下为什么吗?

0 个答案:

没有答案
相关问题