directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shing Hing Man <mat...@yahoo.com>
Subject Problem adding new object class
Date Sun, 15 Apr 2007 18:21:51 GMT
I am trying to add a new object class in Java using
the 
sample code at 
http://java.sun.com/products/jndi/tutorial/ldap/schema/object.html#ADD
(or see the listing  below).
But I get the following exception.



javax.naming.NameNotFoundException: [LDAP: error code
32 - failed to modify entry
2.5.4.3=schema,2.5.4.11=system: Attempt to lookup
non-existant entry: 2.5.4.3=schema,2.5.4.11=system];
remaining name ''
	at
com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3010)
	at
com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2931)
	at
com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2737)
	at
com.sun.jndi.ldap.LdapCtx.c_modifyAttributes(LdapCtx.java:1370)
	at
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_modifyAttributes(ComponentDirContext.java:235)
	at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(PartialCompositeDirContext.java:147)
	at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(PartialCompositeDirContext.java:136)
	at
com.sun.jndi.ldap.LdapSchemaCtx$SchemaInfo.modifyAttributes(LdapSchemaCtx.java:413)
	at
com.sun.jndi.ldap.LdapSchemaCtx.addServerSchema(LdapSchemaCtx.java:276)
	at
com.sun.jndi.ldap.LdapSchemaCtx.doCreateSubcontext(LdapSchemaCtx.java:196)
	at
com.sun.jndi.toolkit.dir.HierMemDirCtx.createSubcontext(HierMemDirCtx.java:375)
	at
com.sun.jndi.toolkit.dir.HierMemDirCtx.createSubcontext(HierMemDirCtx.java:368)
	at
sunTrail.AddObjectClass.main(AddObjectClass.java:56)

=================================

class AddObjectClass {
   public static void main(String[] args) {

	// Set up environment for creating initial context
	Hashtable env = new Hashtable(11);
	env.put(Context.INITIAL_CONTEXT_FACTORY, 
	    "com.sun.jndi.ldap.LdapCtxFactory");
	env.put(Context.PROVIDER_URL,
"ldap://localhost:10389/o=JNDITutorial");

	// Must authenticate as directory administrator in
order to update schema
	String dns = "uid=admin,ou=system";
	env.put(Context.SECURITY_PRINCIPAL, dns);
	env.put(Context.SECURITY_CREDENTIALS, "jrisk");
	env.put(Context.SECURITY_AUTHENTICATION, "simple");

	// This is required when using Netscape Directory
Server 3.x
	// env.put("com.sun.naming.netscape.schemaBugs",
"true");

	try {
	    // Specify attributes for schema object
	    Attributes attrs = new BasicAttributes(true); //
ignore case
	    attrs.put("NUMERICOID",
"1.3.6.1.4.1.42.2.27.4.2.3.1.1.1");
	    attrs.put("NAME", "fooObjectClass");
	    attrs.put("DESC", "for JNDITutorial example
only");
	    attrs.put("SUP", "top");
	    attrs.put("STRUCTURAL", "true");
	    Attribute must = new BasicAttribute("MUST",
"cn");
	    must.add("objectclass");
	    attrs.put(must);

	    // Create the initial context
	    DirContext ctx = new InitialDirContext(env);
	    // Get the schema tree root
	    DirContext schema = ctx.getSchema("");
	
	  
	    // Add new schema object for "fooObjectClass"
   	   DirContext newClass = schema.createSubcontext( 
 //<-- line 56
		"ClassDefinition/fooObjectClass", attrs);

	    // Get new initial context to avoid seeing cached
data
	    ctx.close();
	    ctx = new InitialDirContext(env);
	    schema = ctx.getSchema("");

	    // See what was added
	    System.out.println(
	
schema.getAttributes("ClassDefinition/fooObjectClass"));

	    // Close the context when we're done
	    ctx.close();
	} catch (NamingException e) {
	    e.printStackTrace();
	}
   }
}
=======================
It would be appreciated if some kind soul can tell me 
to how to resolve the above the exception.

Thanks!

Shing

Home page :
  http://uk.geocities.com/matmsh/index.html


      ___________________________________________________________ 
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html


Mime
View raw message