Hi Emmanuel, Thanks, that's much better and far more readable. :)
This is an interesting issue. I could play with the code you provided and I suspect an issue in the schema handling. Either something not enabled correctly or something deeper in the server. Investigating... Regards, Pierre-Arnaud On 22 juil. 2013, at 19:43, Emmanuel GUITON <emmanuel.gui...@intrinsec.com> wrote: > Hi, > > Very sorry for the inconvenience, I hope this time will be better : > > In an embbeded Apache DS instance, I am trying to add an entity using a > custom object class but it fails. Here is the scenario : > First, I set up a default Apache DS instance, with the schema defined in > (maven) : > <dependency> > <groupId>org.apache.directory.api</groupId> > <artifactId>api-ldap-schema-data</artifactId> > <version>1.0.0-M19</version> > </dependency> > Then, I add (programatically) my custom type using the JNDI. This type > extends the 'organization' object class. Browsing the schema with a GUI tool > (JXplorer), I ensure my custom object class was successfully added. > After that, I add a new entity (using the JNDI once again or using the GUI > tool) and the following exception is thrown : > > javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - > OBJECT_CLASS_VIOLATION: failed for MessageType : ADD_REQUEST > Message ID : 5 > Add Request : > Entry > dn[n]: o=Test,dc=company,dc=com > objectClass: orgExtended > o: Test > OpaqueControl Control > Type OID : '2.16.840.1.113730.3.4.2' > Criticality : 'false' > ' > : ERR_277 Attribute o not declared in objectClasses of entry > o=Test,dc=company,dc=com]; remaining name 'o=Test,dc=company,dc=com' > > However, I did specify the value of the 'o' attribute, which is defined in > the parent object class (organization). > I stress that the object class definition includes a SUP attribute. I have > other custom object classes without SUP attribute. I can successfully create > new entities using these other object classes. > > Is this a bug or am I missing something ? > Hereafter, you can find a complete (client side) code snippet to repeat this > behaviour. > > Thanks for any help, > - emmanuel > > > package com.company.directory.client; > > import java.util.Hashtable; > import javax.naming.Context; > import javax.naming.Name; > import javax.naming.NamingException; > import javax.naming.directory.Attributes; > import javax.naming.directory.BasicAttributes; > import javax.naming.directory.DirContext; > import javax.naming.directory.InitialDirContext; > import javax.naming.ldap.LdapName; > > public class ApacheDsTest > { > public static void main(final String[] args) > { > try > { > // Init connection to the LDAP server > final Hashtable<String, String> env = new > Hashtable<String, String>(); > env.put(Context.INITIAL_CONTEXT_FACTORY, > "com.sun.jndi.ldap.LdapCtxFactory"); > env.put(Context.PROVIDER_URL, TestUtils.PROVIDER_URL); > env.put(Context.SECURITY_AUTHENTICATION, "simple"); > env.put("java.naming.ldap.derefAliases", "always"); > env.put(Context.SECURITY_PRINCIPAL, > "uid=admin,ou=system"); > env.put(Context.SECURITY_CREDENTIALS, "secret"); > final DirContext context = new InitialDirContext(env); > > // Add new objectClass, extends organization > final Attributes attrs = new BasicAttributes(); > attrs.put("NUMERICOID", "1.3.6.1.4.1.8654.4.1"); > attrs.put("NAME", "orgExtended"); > attrs.put("DESC", "Extension of the organization > object class"); > attrs.put("SUP", "organization"); > attrs.put("STRUCTURAL", "TRUE"); > final DirContext schemaContext = context.getSchema(""); > > schemaContext.createSubcontext("ClassDefinition/orgExtended", attrs); > > // "dn: o=Test,dc=company,dc=com", "objectClass: > orgExtended", "o: Test" > final Name name = new > LdapName("o=Test,dc=company,dc=com"); > final Attributes attributes=new BasicAttributes(); > attributes.put("objectClass", "orgExtended"); > attributes.put("o", "Test"); > context.createSubcontext(name, attributes); > } > catch (final NamingException exception) > { > System.err.println(exception); > } > } > } > > > > > > Emmanuel GUITON > > Ingénieur Développement > Fixe : +33 1 70 92 84 16 l Standard : +33 1 41 91 77 77 > > 215, Avenue Georges Clemenceau l 92024 Nanterre > http://www.intrinsec.com/ > http://www.intrinsec.com/ > > > -----Message d'origine----- > > De : Pierre-Arnaud Marcelot [mailto:paj...@gmail.com] De la part de > Pierre-Arnaud Marcelot > Envoyé : Monday, July 22, 2013 7:26 PM > À : Apache Directory Developers List > Cc : Emmanuel GUITON > Objet : Re: Failure when creating a new entity using a custom object class > that includes a SUP attribute > > Hi Emmanuel, > > I don't know if it's your mail client but your mail got to us in a pretty bad > shape.... :( > > Could you try to re-send it again with proper formatting? Thanks! > > Regards, > Pierre-Arnaud > > On 22 juil. 2013, at 19:17, Emmanuel GUITON <emmanuel.gui...@intrinsec.com> > wrote: > >> Hello,In an embbeded Apache DS instance, I am trying to add an entity using >> a custom object class but it fails. Here is the scenario :First, I set up a >> default Apache DS instance, with the schema defined in (maven) : >> <dependency> >> <groupId>org.apache.directory.api</groupId> >> <artifactId>api-ldap-schema-data</artifactId> >> <version>1.0.0-M19</version> </dependency>Then, I add >> (programatically) my custom type using the JNDI. This type extends the >> 'organization' object class. Browsing the schema with a GUI tool (JXplorer), >> I ensure my custom object class was successfully added.After that, I add a >> new entity (using the JNDI once again or using the GUI tool) and the >> following exception is thrown >> :javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - >> OBJECT_CLASS_VIOLATION: failed for MessageType : ADD_REQUESTMessage ID : 5 >> Add Request :Entry dn[n]: o=Test,dc=company,dc=com objectClass: >> orgExtended o: Test OpaqueControl Control Type OID : >> '2.16.840.1.113730.3.4.2' Criticality : 'false'': ERR_277 Attribute o >> not declared in objectClasses of entry o=Test,dc=company,dc=com]; remaining >> name 'o=Test,dc=company,dc=com'However, I did specify the value of the 'o' >> attribute, which is defined in the parent object class (organization).I >> stress that the object class definition includes a SUP attribute. I have >> other custom object classes without SUP attribute. I can successfully create >> new entities using these other object classes.Is this a bug or am I missing >> something ?Hereafter, you can find a complete (client side) code snippet to >> repeat this behaviour.Thanks for any help, - emmanuelpackage >> com.company.directory.client;import java.util.Hashtable;import >> javax.naming.Context;import javax.naming.Name;import >> javax.naming.NamingException;import javax.naming.directory.Attributes;import >> javax.naming.directory.BasicAttributes;import >> javax.naming.directory.DirContext;import >> javax.naming.directory.InitialDirContext;import >> javax.naming.ldap.LdapName;public class ApacheDsTest{ public static >> void main(final String[] args) { try { >> // Init connection to the LDAP server final >> Hashtable<String, String> env = new Hashtable<String, String>(); >> env.put(Context.INITIAL_CONTEXT_FACTORY, >> "com.sun.jndi.ldap.LdapCtxFactory"); >> env.put(Context.PROVIDER_URL, TestUtils.PROVIDER_URL); >> env.put(Context.SECURITY_AUTHENTICATION, "simple"); >> env.put("java.naming.ldap.derefAliases", "always"); >> env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system"); >> env.put(Context.SECURITY_CREDENTIALS, "secret"); >> final DirContext context = new InitialDirContext(env); >> // Add new objectClass, extends organization >> final Attributes attrs = new BasicAttributes(); >> attrs.put("NUMERICOID", "1.3.6.1.4.1.8654.4.1"); >> attrs.put("NAME", "orgExtended"); attrs.put("DESC", >> "Extension of the organization object class"); >> attrs.put("SUP", "organization"); >> attrs.put("STRUCTURAL", "TRUE"); final DirContext >> schemaContext = context.getSchema(""); >> schemaContext.createSubcontext("ClassDefinition/orgExtended", attrs); >> // "dn: o=Test,dc=company,dc=com", >> "objectClass: orgExtended", "o: Test" final Name name >> = new LdapName("o=Test,dc=company,dc=com"); final >> Attributes attributes=new BasicAttributes(); >> attributes.put("objectClass", "orgExtended"); >> attributes.put("o", "Test"); >> context.createSubcontext(name, attributes); } >> catch (final NamingException exception) { >> System.err.println(exception); } }} >> >> >> Emmanuel GUITON >> >> Ingénieur Développement >> Fixe : +33 1 70 92 84 16 l Standard : +33 1 41 91 77 77 >> >> 215, Avenue Georges Clemenceau l 92024 Nanterre >> http://www.intrinsec.com/ http://www.intrinsec.com/ >> >> >> >> > >