[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#4470) how to use JNDI to extend schema

Full_Name: cuimeng
Version: openldap 2.2.19
OS: windows xp home edition
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

when I use JNDI to add an attribute to openldap schema, I get a problem,
following is my program.

import javax.naming.directory.*;
import javax.naming.*;
import java.util.Hashtable;
public class add {
   public add() {

  public static void main(String[] args) {
 String password = "cm"; 
   String basedn = "dc=cm,dc=com"; 
   DirContext ctx = null;
   Hashtable env = new Hashtable();
  env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
  env.put(Context.PROVIDER_URL, "ldap://localhost:389/"+basedn ); 
  env.put(Context.SECURITY_AUTHENTICATION, "simple"); 
  env.put(Context.SECURITY_PRINCIPAL, "cn=root,"+basedn ); 
  env.put(Context.SECURITY_CREDENTIALS, password);
  try {
    ctx = new InitialDirContext(env); 
    System.out.println("connect ok");
  catch (Exception e) {

   DirContext schemaCtx = ctx.getSchema("");
   BasicAttributes attrs = new BasicAttributes(true);
   attrs.put("NAME", "test");
   attrs.put("NUMERICOID", "");
   attrs.put("SYNTAX", "");
   attrs.put("SINGLE-VALUE", "TRUE");
   schemaCtx.createSubcontext("AttributeDefinition/test", attrs);
  }catch(Exception e){
  System.out.println("Exception in add():"+e);

I get the exception

Exception in add():javax.naming.OperationNotSupportedException: [LDAP: error
code 53 - modification of subschema subentry not supported]; remaining name ''

on trying to add an attribute.
All help is welcome,
Thank you