[ApacheDS] ERR_04269 ATTRIBUTE_TYPE for OID documentidentifier does not exists

I am trying to add a document to an ou programatically.  I am using ApacheDS 
2.0.0-M17.  I am also using Apache Directory Studio 2.0.0.v20130628.

I am able to connect to the server localhost, at port 10389, and am working in 
partition dc=test,dc=com (for this example).

The following organizational units exist in the partition - persistent 
(ou=persistent,dc=test,dc=com), and under persistent, documentStore 
(ou=documentStore,ou=persistent,dc=test,dc=com).

If I import a document into the documentStore ou using an ldif import, it 
works.  The ldif file contains only the following lines:

dn: documentIdentifier=D1,ou=documentStore,ou=persistent,dc=test,dc=com
objectClass: document
documentIdentifier: D1

I can also create the document by right clicking on the ou node in the LDAP 
browser, selecting New->New Entry (or New->New Context Entry; both seem to open 
the same dialog).  In the dialog, I select Create entry from scratch, click 
Next, and select document from the Available object classes.  This adds 
document and top to the Selected object classes.  I then click Next.  For RDN, 
I enter documentIdentifier and D2 to the entry fields, and click (yep, you 
guessed it!) Next.  This shows three attributes ... two objectClass values 
(document and top), and one documentIdentifier value (D2), as expected.  The 
dialog indicates that these are must attributes.  I then click Finish, and the 
document node is displayed in the LDAP Browser in AD
Studio.

Next, I try to create a document entry from a short java program.  I can 
successfully create an ou using the program, by creating an InitialDirContext 
(let's call it idc.  I can then create an ou using the following code:

// The InitialDirContext is created using dn: 
ou=documentStore,ou=persistent,dc=test,dc=com
// The argument ouName is set to the value ou=anotherOu
  public void createOu( String ouName )
  {
    try
    {
      // CreateOu attributes to be associated with the new context
      Attributes attrs = new BasicAttributes(true); // case-ignore
      Attribute objclass = new BasicAttribute("objectclass");
      objclass.add("top");
      objclass.add("organizationalUnit");
      attrs.put(objclass);

      // CreateOu the context
      Context result = idc.createSubcontext(ouName, attrs);

      // Close the context when we're done
      result.close();
    }
    catch ( NamingException e )
    {
      System.err.println( "LdapTest::createOu(): " + e.getMessage() );
      e.printStackTrace();
    }
  }

This code completes successfully, and the new ou, anotherOu, is visible in the 
LDAP Browser, when I reload the directoryStore ou.

Finally, I modify the code above to attempt to programatically add a document 
to the documentStore ou.  The modified code is as follows:

// The InitialDirContext is created using dn: 
ou=documentStore,ou=persistent,dc=test,dc=com
// The argument docName is set to the value documentIdentifier=D3
  public void createDocument( String docName )
  {
    try
    {
      // CreateOu attributes to be associated with the new context
      Attributes attrs = new BasicAttributes(true); // case-ignore
      Attribute objclass = new BasicAttribute("objectclass");
      objclass.add("top");
      objclass.add("document");
      attrs.put(objclass);

      // CreateOu the context
      Context result = idc.createSubcontext(docName, attrs);

      // Close the context when we're done
      result.close();
    }
    catch ( NamingException e )
    {
      System.err.println( "LdapTest::createDocument(): " + e.getMessage() );
      e.printStackTrace();
    }
  }

When I run this code, I get the following exception message and stack trace:

LdapTest::createDocument(): [LDAP: error code 16 - NO_SUCH_ATTRIBUTE: failed 
for MessageType : ADD_REQUEST
Message ID : 2
    Add Request :
Entry
    dn[n]: documentIdentifer=D3,ou=documentStore,ou=persistent,dc=test,dc=com

    documentIdentifer: D3
    ManageDsaITImpl Control
        Type OID    : '2.16.840.1.113730.3.4.2'
        Criticality : 'false'
'
: ERR_04269 ATTRIBUTE_TYPE for OID documentidentifer does not exist!]
javax.naming.directory.NoSuchAttributeException: [LDAP: error code 16 - 
NO_SUCH_ATTRIBUTE: failed for MessageType : ADD_REQUEST
Message ID : 2
    Add Request :
Entry
    dn[n]: documentIdentifer=D3,ou=documentStore,ou=persistent,dc=test,dc=com

    documentIdentifer: D3
    ManageDsaITImpl Control
        Type OID    : '2.16.840.1.113730.3.4.2'
        Criticality : 'false'
'
: ERR_04269 ATTRIBUTE_TYPE for OID documentidentifer does not exist!]; 
remaining name 'documentIdentifer=D3'
        at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3108)
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3033)
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2840)
        at com.sun.jndi.ldap.LdapCtx.c_createSubcontext(LdapCtx.java:811)
        at 
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_createSubcontext(ComponentDirContext.java:337)
        at 
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(PartialCompositeDirContext.java:266)
        at 
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(PartialCompositeDirContext.java:254)
        at 
javax.naming.directory.InitialDirContext.createSubcontext(InitialDirContext.java:197)
        at 
com.warsim.aui.ldaptest.CreateContext.createDocument(CreateContext.java:43)
        at com.warsim.aui.ldaptest.CreateContext.main(CreateContext.java:75)

I am a novice LDAP user, and freely admit I don't understand it very well.  Any 
assistance in identifying my error, or identifying a solution, would be greatly 
appreciated.

Reply via email to