Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从JAVA在OpenDJ(LDAP)中创建新的对象类_Java_Ldap - Fatal编程技术网

从JAVA在OpenDJ(LDAP)中创建新的对象类

从JAVA在OpenDJ(LDAP)中创建新的对象类,java,ldap,Java,Ldap,我必须从JavaJNDI在LDAP服务器中创建一个自定义对象类。对象类应该有3个带值的字段:名称、OID、描述。到目前为止 我只设法定义了环境 Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); properties.put(Context.PROVIDER_URL, ldapU

我必须从JavaJNDI在LDAP服务器中创建一个自定义对象类。对象类应该有3个带值的字段:名称、OID、描述。到目前为止 我只设法定义了环境

Properties properties = new Properties();

    properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    properties.put(Context.PROVIDER_URL, ldapUrl);
    properties.put(Context.REFERRAL, "ignore");
    properties.put(Context.SECURITY_PRINCIPAL, dirManagerUser);
    properties.put(Context.SECURITY_CREDENTIALS, password);

    DirContext ctx = new InitialDirContext(properties);

    //NEW CUSTOM OBJECT CREATION SHOULD GO HERE

    ctx.close();
我找到了一个解决方案:

BasicAttribute attribute = new BasicAttribute("objectClasses");
        attribute.add(parameters);
        attributes.put(attribute);
        context.modifyAttributes("cn=schema",DirContext.ADD_ATTRIBUTE, attributes);
        context.close();

为什么来自Java?你可以用行政手段。你只需要做一次。在不需要的时候编写代码是没有意义的。这不是由我来决定的。这是一项既定的任务。