Ldap 向对象类添加新属性,并希望它自动显示在Apache DS中的现有对象中

Ldap 向对象类添加新属性,并希望它自动显示在Apache DS中的现有对象中,ldap,apacheds,Ldap,Apacheds,我正在处理一个用例,在这个用例中,我必须动态地向ApacheDS中现有的对象类添加一个新属性 1以下是一些定义我的对象类的代码:- Attributes attrs = new BasicAttributes(true); attrs.put("NUMERICOID", "1.3.6.1.4.1.18060.0.4.3.3.1"); attrs.put("NAME", "ship"); attrs.put("DESC", "An e

我正在处理一个用例,在这个用例中,我必须动态地向ApacheDS中现有的对象类添加一个新属性

1以下是一些定义我的对象类的代码:-

        Attributes attrs = new BasicAttributes(true);
        attrs.put("NUMERICOID", "1.3.6.1.4.1.18060.0.4.3.3.1");
        attrs.put("NAME", "ship");
        attrs.put("DESC", "An entry which represents a ship");
        attrs.put("SUP", "top");
        attrs.put("STRUCTURAL", "true");

        Attribute must = new BasicAttribute("MUST");
        must.add("cn");
        attrs.put(must);

        Attribute may = new BasicAttribute("MAY");
        may.add("numberOfGuns");
        may.add("numberOfGuns2");
        may.add("description");
        attrs.put(may);

        //add
        schema.createSubcontext("ClassDefinition/ship", attrs);
2添加该对象类的对象:

Attributes attributes=new BasicAttributes();
Attribute objectClass=new BasicAttribute("objectClass");
objectClass.add("ship");
attributes.put(objectClass);

Attribute g=new BasicAttribute("numberOfGuns");
Attribute g2=new BasicAttribute("numberOfGuns2");
Attribute cn=new BasicAttribute("cn");


g.add("2");
g2.add("3");
cn.add("four");


attributes.put(g);
attributes.put(cn);
attributes.put(g2);
;

ctx.createSubcontext("cn=four,dc=example,dc=com",attributes);
3向对象类添加新属性-“mustA”

        Attributes attrs = new BasicAttributes(true);
        attrs.put("NUMERICOID", "1.3.6.1.4.1.18060.0.4.3.3.1");
        attrs.put("NAME", "ship");
        attrs.put("DESC", "An entry which represents a ship");
        attrs.put("SUP", "top");
        attrs.put("STRUCTURAL", "true");

        Attribute must = new BasicAttribute("MUST");
        must.add("cn");
        must.add("mustA");
        attrs.put(must);

        Attribute may = new BasicAttribute("MAY");
        may.add("numberOfGuns");
        may.add("numberOfGuns2");
        may.add("description");
        attrs.put(may);

        //modify
        schema.modifyAttributes("ClassDefinition/ship",DirContext.ADD_ATTRIBUTE ,attrs);
一旦添加了新属性,这意味着修改了对象类,如果我添加了该对象类类型的新对象,我可以在新创建的对象中看到新添加的属性

我的问题是,在添加新属性之前创建的对象会发生什么情况?如何使新属性自动显示在现有对象中?例如,新属性mustA是否会自动显示在对象4中


或者我必须手动修改该对象以添加新属性吗?

您需要更新模式。对于ApacheDS,最简单的方法是下载并查看2.3.1-

哦,你会一直得到我的大力支持。开发人员非常活跃

AFIK、ApacheDs将支持从LDAP调用添加模式,但我不能肯定。看

如果您坚持要以艰难的方式完成此任务,请查看以下示例:


-吉姆

谢谢你的回答。我想用JNDI来完成所有这些,而不使用Apache目录StudioSo。您看了吗:是的,Jim,链接中有关于如何创建对象类和修改对象类等的信息,但没有说明对修改后的对象类的现有条目的影响。从我所了解的情况来看,我发现在修改对象类(如向其添加新属性)之后,应该修改该对象类的每个现有条目。我想知道它们是否是刷新现有条目的一种方法,以便它们自动显示新属性。该属性将在具有修改的ObjectClass的每个条目上可用。与许多LDAP服务器实现一样,如果要使用添加的AttributeType或ObjectClass,则必须重新启动服务器,因为模式当前在ApacheDS中不是动态的。