Reputation: 3771
I would like to recreate the following ldiff using java:
DN: name=myName,ef=X2,ou=OuControls,o=Test,c=DE
objectClass: top
objectClass: myComponent
name: myName
The problem ist that I can't specify multiple objectClass Attributes.
If I examine the created node I only see the objectClass: myComponent attribute.
My code looks like this:
BasicAttribute oc1 = new BasicAttribute("objectClass","top");
final DirContext context = LDAP_SERVICE.getContext();
Attributes attrs = new BasicAttributes(true);
attrs.put(oc1);
BasicAttribute oc2 = new BasicAttribute("objectClass","myComponent");
attrs.put(oc2);
attrs.put("name", "myName");
context.bind("name=myName,ef=X2,ou=OuControls,o=Test,c=DE", null, attrs);
The question is, how do I specify two attributes with the same name ?
Regards Roger
Upvotes: 1
Views: 1918
Reputation: 10986
Something like this should work for you (Works for me):
Attribute attr = new BasicAttribute("objectClass");
attr.add("top");
attr.add("myComponent");
-jim
Upvotes: 2