Hi,

I'm trying to automate the process of adding attributes to our iPlanet
Directory to help reduce keying errors when implementing applications
that have changed the directory's schema.

I've successfully done this but all attributes I add appear as multi
value in iPlanet.   What am I doing wrong?   We're running with v5.1.

Code snippet:-
    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:399/dc=andee";);

        // Must be directory admin in order to update schema
        env.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
        env.put(Context.SECURITY_CREDENTIALS, "xxxxxxxx");
        env.put(Context.SECURITY_AUTHENTICATION, "simple");

        try {
            // Define attribute
            Attributes attrs = new BasicAttributes(true); 
            attrs.put("NUMERICOID", "andee1-oid");
            attrs.put("NAME", "andee1");
            attrs.put("DESC", "Andee test");
            attrs.put("SYNTAX", "1.3.6.1.4.1.1466.115.121.1.15");


            // Create the initial context
            DirContext ctx = new InitialDirContext(env);

            // Get the schema tree root
            DirContext schema = ctx.getSchema("");

            // Add new schema object for "andee1"
            DirContext newAttr = schema.createSubcontext(
                "AttributeDefinition/andee1", attrs);

            // Get new initial context to avoid seeing cached data
            ctx.close();

        } catch (NamingException e) {
            e.printStackTrace();
        }
    }


Thanks,

Andee

Reply via email to