0
次のコードを使用して、Spring LDAPを使用して認証しています。Spring LDAPでNPEを送信する
public static void main(String[] args) {
String username = "kgam";
String password = "password";
LdapContextSource ctxSrc = new LdapContextSource();
ctxSrc.setUrl(URL);
ctxSrc.setBase(BASE);
ctxSrc.setUserDn(USERDN);
ctxSrc.setPassword(PASSWORD);
LdapTemplate ldapTemplate = new LdapTemplate(ctxSrc);
AndFilter filter = new AndFilter();
ldapTemplate.setIgnorePartialResultException(true);
filter.and(new EqualsFilter("objectClass", "person")).and(new EqualsFilter("sAMAccountName", username));
System.out.println(ldapTemplate.authenticate(BASE, filter.toString(), password));
}
次のスタックトレースでNPEをスローします。
Exception in thread "main" java.lang.NullPointerException
at org.springframework.ldap.core.support.AbstractContextSource.getReadOnlyContext(AbstractContextSource.java:138)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:286)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:236)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:623)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:534)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:461)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:482)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:502)
at org.springframework.ldap.core.LdapTemplate.authenticate(LdapTemplate.java:1481)
at org.springframework.ldap.core.LdapTemplate.authenticate(LdapTemplate.java:1398)
at com.capitalone.dashboard.service.AuthenticationServiceImpl.main(AuthenticationServiceImpl.java:123)
私はここでどこが間違っていますか?