Results 1 to 5 of 5

Thread: How to create ldap root contexts using spring ldap api?

  1. #1

    Default How to create ldap root contexts using spring ldap api?

    Hi,

    I have a requirement of creating the ldap root context by using spring ldap api.

    Do we have any spring ldap api to create the ldap root context?

    Thanks
    Venkat

  2. #2
    Join Date
    Jul 2005
    Location
    Helsingborg, Sweden
    Posts
    504

    Default

    There is a description on how to create a root context in this thread.
    Ulrik Sandberg
    Jayway (www.jayway.com)
    Spring LDAP project member

  3. #3

    Default

    Thanks ULSA. This is good enough for my requirment.

  4. #4

    Default

    Hi,

    When i am trying to create the root context in the ldap by using below code which is posted above link.

    public void createRootContextWithDirContextAdapter() throws Exception {
    final String ROOT_CONTEXT = "dc=example2,dc=example3";
    DirContextAdapter adapter = new DirContextAdapter();
    adapter.setAttributeValues("objectclass",
    new String[] { "top", "inetOrgPerson" });
    ldapTemplate.bind(ROOT_CONTEXT, adapter, null);}




    *********I am getting the following error.****************
    Feb 9, 2010 10:58:19 AM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [spring-ldap.xml]
    org.springframework.ldap.NameNotFoundException: [LDAP: error code 32 - The provided entry dc=example2,dc=example3 cannot be added because its suffix is not defined as one of the suffixes within the Directory Server]; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - The provided entry dc=example2,dc=example3 cannot be added because its suffix is not defined as one of the suffixes within the Directory Server]; remaining name 'dc=example2,dc=example3'
    at org.springframework.ldap.support.LdapUtils.convert LdapException(LdapUtils.java:172)
    at org.springframework.ldap.core.LdapTemplate.execute WithContext(LdapTemplate.java:810)
    at org.springframework.ldap.core.LdapTemplate.execute ReadWrite(LdapTemplate.java:802)
    at org.springframework.ldap.core.LdapTemplate.bind(Ld apTemplate.java:1010)
    at ldap.LDAPTenantDAO.createRootContextWithDirContext Adapter(LDAPTenantDAO.java:159)
    at ldap.LDAPServices.createRootContextWithDirContextA dapter(LDAPServices.java:78)
    at client.SpringFrameworkLDAPClient.main(SpringFramew orkLDAPClient.java:46)
    Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - The provided entry dc=example2,dc=example3 cannot be added because its suffix is not defined as one of the suffixes within the Directory Server]; remaining name 'dc=example2,dc=example3'
    at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.jav a:3030)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2951)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2758)
    at com.sun.jndi.ldap.LdapCtx.c_bind(LdapCtx.java:383)
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bin d(ComponentDirContext.java:277)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContex t.bind(PartialCompositeDirContext.java:197)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContex t.bind(PartialCompositeDirContext.java:186)
    at javax.naming.directory.InitialDirContext.bind(Init ialDirContext.java:158)
    at org.springframework.ldap.core.LdapTemplate$22.exec uteWithContext(LdapTemplate.java:1012)
    at org.springframework.ldap.core.LdapTemplate.execute WithContext(LdapTemplate.java:807)
    ... 5 more

    *************************************************



    *********My configuration file is:********
    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapC ontextSource">
    <property name="url" value="ldap://localhost:389/">
    </property>
    <property name="userDn" value="cn=venkat" />
    <property name="password" value="venkat" />
    </bean>

    **********************************


    Can you please guide me where i am doing wrong?

    Thanks
    Venkata

  5. #5
    Join Date
    Jul 2005
    Location
    Helsingborg, Sweden
    Posts
    504

    Default

    You need to tell your directory server configuration that you have the root context. In OpenLDAP, for example, you specify it in the slapd.conf file:

    Code:
    suffix "dc=example2,dc=example3"
    You may have more than one suffix:

    Code:
    suffix "dc=example,dc=com"
    suffix "dc=example,dc=org"
    Ulrik Sandberg
    Jayway (www.jayway.com)
    Spring LDAP project member

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •