1

I am following this article on setting LDAP Authentication with Spring
Now I can login to the application, but I get this exception:

Unprocessed Continuation Reference(s); nested exception is javax.naming.PartialResultException: 
Unprocessed Continuation Reference(s); remaining name 'DC=XEROX,DC=AD,DC=XEROX,DC=com'
Caused by: javax.naming.PartialResultException: Unprocessed Continuation Reference(s)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2917) ~[na:1.8.0_144]
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2891) ~[na:1.8.0_144]
    at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1846) ~[na:1.8.0_144]
    at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1769) ~[na:1.8.0_144]

according to other articles I read, I need to set the referral to follow, setReferral("follow");

But I am not sure where to add this to this code:

String completeUrl = new StringBuffer(this.url).append(":")
                    .append(this.port)
                    .append("/")
                    .append(this.contextRoot)
                    .toString();

            auth.ldapAuthentication()
                    .userSearchFilter(userSearchFilter)
                    .userDnPatterns(userDnPatterns)
                    .contextSource()
                    .url(completeUrl)
                    .managerDn(managerDn)
                    .managerPassword(managerPassword);
JavaSheriff
  • 7,074
  • 20
  • 89
  • 159

1 Answers1

0

You should create your own contextSource, something like:

@Bean("internalLdapContextSource")
public LdapContextSource getLdapContextSource() {
    String ldapUrl = env.getProperty("ldap.server");
    String managerDn = env.getProperty("ldap.manager.distinguished.name");
    String managerPassword = env.getProperty("ldap.manager.password");
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl(ldapUrl);
    contextSource.setUserDn(managerDn);
    contextSource.setPassword(managerPassword);
    Map<String, Object> baseEnvironmentProperties = new HashMap<>();
    baseEnvironmentProperties.put("java.naming.referral", "follow");
    contextSource.setBaseEnvironmentProperties(baseEnvironmentProperties);
    return contextSource;
}

You can use setBaseEnvironmentProperties method as shown in the sample or setReferral ( both works fine ).

Finally use .contextSource(getLdapContextSource())

darkman97i
  • 170
  • 7