[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Openldap + JNDI questions


the string in the 1st arg of ctx.bind() is the full DN,
here cn=foo,o=LDAPTest.


-----Original Message-----
From: Anil Dhawan [mailto:cs9e-1af@pasteur.EECS.Berkeley.EDU]
Sent: Monday, May 13, 2002 23:37
To: openldap-software@OpenLDAP.org
Subject: Openldap + JNDI questions

Hi,  I am new to LDAP and JNDI, but have read up some literature and
installed OpenLdap on my linux machine.  I am trying to set up
configuration in which i can add objects to the LDAP directory using
JNDI.. so, i've gone ahead and made the following slapd.conf file:

database        ldbm
suffix          "o=LDAPTest"
rootdn          "cn=Manager,o=LDAPTest"
schemacheck     off
directory       /usr/local/var/openldap-ldbm

Now, in my java code, i have:

       Hashtable env = new Hashtable();

        env.put( Context.INITIAL_CONTEXT_FACTORY,
                 "com.sun.jndi.ldap.LdapCtxFactory" );
        env.put( Context.PROVIDER_URL, "ldap://localhost/o=LDAPTest"; );

        try {
            DirContext ctx = new InitialDirContext( env );

            String name = "myData";
            ctx.bind( "cn=" + name.toString(), name );

            //      System.out.println( name + " is bound to " + obj );

        } catch ( Exception e ) {
            System.err.println( e );

The code compiles fine.. and it seems like it connects to the LDAP server
correctly as well.. but upon execution, i get the following exception
javax.naming.NameNotFoundException: [LDAP: error code 32 - parent does not
exist]; remaining name 'cn=foo'

I can't figure out why this might be... any gurus want to take a shot at
this one?  Any help is appreciated, thanks!