1 Reply Latest reply on Aug 21, 2013 12:42 PM by 1014801

    Using JNDI to Create cnames in LDAP

    1014801

      Hello all,

       

      First off, thank you for taking your time to read my post. As I am new to JNDI, I have a question regarding its integration with LDAP.

       

      I am trying to write a Java program that will add cnames to my LDAP container. I have had some success in that the cname is created, however the objectClass attribute is initialized wrong and I have difficulty changing it. Here is the code that I have now along with the attributes that are initialized:

       

      DirContext ctx = new InitialDirContext(env);
      ctx.createSubcontext("cn=test,ou=orgUnit,o=org");

       

      Attributes:

      cn = test

      objectClass = javaContainer

      objectClass = Top

       

      The correct attributes that I need the cname initialized with are as follows:

       

      Attributes:

      cn = test

      objectClass = groupOfNames

      objectClass = Top

      ACL = ....

      DirXML-Associations = ...

       

      I have had no problem adding the ACL and DirXML-Associationg attributes. I have however tried replacing the existing objectClass attribute with a 'replace' command using the modifyAttributes function with no success. Does anybody have any ideas?


      Thank you!

      Josh

        • 1. Re: Using JNDI to Create cnames in LDAP
          1014801

          Of course I figure it out right after I post the question. To those who may encounter this issue in the future, here is my code:

           

          DirContext ctx = new InitialDirContext(env);

          Attributes attrs = new BasicAttributes(true);

          Attribute cname = new BasicAttribute("objectclass");

          cname.add("top");

          cname.add("groupofnames");

          attrs.put(cname);

          Context result = ctx.createSubcontext("cn=test,ou=orgUnit,o=org", attrs);