directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel GUITON <>
Subject Failure when creating a new entity using a custom object class that includes a SUP attribute
Date Mon, 22 Jul 2013 17:17:23 GMT
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></groupId>
      <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 [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;import java.util.Hashtable;import
javax.naming.Context;import javax.naming.Name;import javax.naming.NamingException;import;import;import;import;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", "");
                       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

View raw message