0

Getting below error while connecting to LDAP via springboot application.

org.springframework.ldap.UncategorizedLdapException: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C090A5A, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v4f7c ]; remaining name '/'


private void initContext() {
    contextSource = new LdapContextSource();

 contextSource.setUrl("ldap://10.55.56.01:389");
        contextSource.setAnonymousReadOnly(true);
        contextSource.setUserDn("sAMAccountName=testldap");
        contextSource.setBase("dc=pmn-test,dc=com");
contextSource.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy());
        contextSource.setPassword("Test123!");
        contextSource.afterPropertiesSet();

        ldapTemplate = new LdapTemplate(contextSource);
    }
Filter filter = new EqualsFilter("sAMAccountName", authentication.getName());

Boolean authenticate = ldapTemplate.authenticate(LdapUtils.emptyLdapName(), filter.encode(), authentication.getCredentials().toString());

Tried by changing properties

 contextSource.setUrl("ldap://10.55.56.01:389");
        contextSource.setAnonymousReadOnly(true);
        contextSource.setUserDn("sAMAccountName=testldap");
        contextSource.setBase("dc=pmn-test,dc=com");
contextSource.setAuthenticationStrategy(new SimpleDirContextAuthenticationStrategy());
        contextSource.setPassword("Test123!");
        contextSource.afterPropertiesSet();

Configured via application properties but taking URL as localhost:389

#spring.ldap.url=ldap://10.55.56.01:389/
#spring.ldap.base=dc=dc=pmn-test,dc=com
#spring.ldap.username=sAMAccountName=testldap
#spring.ldap.password=Test123!

  • Issue resolved by referring this answer - [https://stackoverflow.com/questions/5255158/spring-ldap-bind-for-successful-connection](https://stackoverflow.com/questions/5255158/spring-ldap-bind-for-successful-connection) – Praveen Narahari Nov 02 '22 at 13:56

0 Answers0