Announcement Announcement Module
Collapse
No announcement yet.
Spring LDAP initialization Errors :( Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring LDAP initialization Errors :(

    Hello All,
    I am quite new for the field of Spring LDAP and developping a little java client for the authenticaiton purpuses. What I now really want to do is just to list the set of users of the LDAP server hosted locally. Following would be the spring initialization code for the client.


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapC ontextSource">
    <property name="url" value="ldap://192.168.1.2:389" />
    <property name="base" value="DC=Zone24x7,DC=lk" />
    <property name="userDn" value="my_user" />
    <property name="password" value="abc123" />

    <!--
    <property name="url" value="ldap://localhost:389" />
    <property name="base" value="dc=example,dc=com" />
    <property name="userDn" value="cn=Manager" />
    <property name="password" value="secret" />
    -->

    </bean>

    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
    <constructor-arg ref="contextSource" />
    </bean>

    <bean id="personDao1" class="com.me.PersonDaoImpl">
    <property name="ldapTemplate" ref="ldapTemplate" />
    </bean>
    </beans>


    and i am getting the follwoing error at the console while performing the below code.

    BeanFactory factory = new XmlBeanFactory(new FileSystemResource("ldap-config.xml"));
    PersonDao pd_new = (PersonDao) factory.getBean("personDao1");


    Console Error :

    log4j:WARN No appenders could be found for logger (org.springframework.util.ClassUtils).
    log4j:WARN Please initialize the log4j system properly.
    Exception in thread "main" org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece
    at org.springframework.ldap.support.LdapUtils.convert LdapException(LdapUtils.java:180)
    at org.springframework.ldap.core.support.AbstractCont extSource.createContext(AbstractContextSource.java :266)
    at org.springframework.ldap.core.support.AbstractCont extSource.getContext(AbstractContextSource.java:10 6)
    at org.springframework.ldap.core.support.AbstractCont extSource.getReadOnlyContext(AbstractContextSource .java:125)
    at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:287)
    at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:259)
    at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:571)
    at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:556)
    at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:411)
    at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:431)
    at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:451)
    at com.me.PersonDaoImpl.getAllPersonNames(PersonDaoIm pl.java:19)
    at Main.main(Main.java:24)
    Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece
    at com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown Source)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknow n Source)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknow n Source)
    at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
    at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unkno wn Source)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unkn own Source)
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstanc e(Unknown Source)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext (Unknown Source)
    at javax.naming.spi.NamingManager.getInitialContext(U nknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unkn own Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.ldap.InitialLdapContext.<init>(Unknow n Source)
    at org.springframework.ldap.core.support.LdapContextS ource.getDirContextInstance(LdapContextSource.java :43)
    at org.springframework.ldap.core.support.AbstractCont extSource.createContext(AbstractContextSource.java :254)
    ... 11 more




    The Username/password and other connection details are perfectly true. ( i can login the LDAP server with the same details through the client-software 'LDAPadmin')

    Please be kind enough to tell me where is wrong and what should i do to eliminate these Authentication errors.

    Thanking a lot in advance.
    Sriya

  • #2
    The userDN supplied to the ContextSource needs to be the full DN of the admin user. You seem to supply a relative one.

    Comment


    • #3
      Spring LDAP initialization Errors

      Hello rasky,

      Thank you very much for your sort, quick and perfect answer. yes, that was the problem, I replaced userDN value with the Full DN as follows.

      <property name="userDn" value="CN=My User,CN=Users,DC=Zone24x7,DC=lk" />

      but unfortunately i am getting the following set of errors on my console with the modified program.

      Console Errors :

      log4j:WARN No appenders could be found for logger (org.springframework.util.ClassUtils).
      log4j:WARN Please initialize the log4j system properly.
      Exception in thread "main" org.springframework.ldap.PartialResultException: Unprocessed Continuation Reference(s); nested exception is javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name ''
      at org.springframework.ldap.support.LdapUtils.convert LdapException(LdapUtils.java:203)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:315)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:259)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:571)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:556)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:411)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:431)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:451)
      at com.me.PersonDaoImpl.getAllPersonNames(PersonDaoIm pl.java:19)
      at Main.main(Main.java:24)
      Caused by: javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name ''
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknow n Source)
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknow n Source)
      at com.sun.jndi.ldap.LdapNamingEnumeration.getNextBat ch(Unknown Source)
      at com.sun.jndi.ldap.LdapNamingEnumeration.hasMoreImp l(Unknown Source)
      at com.sun.jndi.ldap.LdapNamingEnumeration.hasMore(Un known Source)
      at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:295)
      ... 8 more



      Please note that i am using the following method "getAllPersonNames()" to extract the list of names of the users at LDAP server.

      package com.me;
      import java.util.List;
      import javax.naming.NamingException;
      import javax.naming.directory.Attributes;
      import org.springframework.ldap.core.AttributesMapper;
      import org.springframework.ldap.core.LdapTemplate;


      public class PersonDaoImpl implements PersonDao {
      private LdapTemplate ldapTemplate;

      public void setLdapTemplate(LdapTemplate ldapTemplate) {
      this.ldapTemplate = ldapTemplate;
      }

      public List getAllPersonNames() {
      return ldapTemplate.search(
      "", "(objectclass=person)", new AttributesMapper() {public Object mapFromAttributes(Attributes attrs)
      throws NamingException { return attrs.get("cn").get();}}
      );
      }
      }


      Your consideration is highly appreciated.

      Thanks once again..
      Sriya

      Comment


      • #4
        The class org.springframework.ldap.core.LdapTemplate have a method setIgnorePartialResultException set like true default value is false.

        ldapTemplate.setIgnorePartialResultException(true) ;

        Please view:
        http://jira.springframework.org/browse/SEC-1098

        Comment

        Working...
        X