Thanks for your response.
I get the following error if I try to add a group in an existing group:
Code:
javax.naming.InvalidNameException: cn=junitTestGroup, cn=junitTestGroup, ou=groups, o=DEMOCORP, c=AU: [LDAP: error code 64 - Naming Violation]; remaining name 'cn=junitTestGroup, cn=junitTestGroup, ou=groups, o=DEMOCORP, c=AU'
During my test the group "cn=junitTestGroup, ou=groups, o=DEMOCORP, c=AU" exists. I want to add "cn=junitTestGroup" group in the existing group.
Relevent part of my code:
Code:
private DistinguishedName buildDn() {
DistinguishedName dn = new DistinguishedName();
dn.add("c", "AU");
dn.add("o", "DEMOCORP");
dn.add("ou", "groups");
dn.add("cn", "junitTestGroup");
dn.add("cn", "junitTestGroup");
return dn;
}
private DirContextOperations setAttributes(DirContextOperations adapter) {
adapter.setAttributeValues("objectclass", new String[] { "top",
"groupOfUniqueNames" });
adapter.setAttributeValue("cn", "junitTestGroup");
if (group.getMembers() != null && group.getMembers().size() > 0) {
adapter.setAttributeValues("uniqueMember", group.getMembers()
.toArray(new String[0]));
}
return adapter;
}
I even tried adding "organizationalUnit" objectclass in the setAttributes method but got the following error when creating the first (parent) group.
Code:
javax.naming.directory.InvalidAttributeValueException: [LDAP: error code 21 - Invalid Attribute Syntax]; remaining name 'ou=junitTestGroup, ou=groups, o=DEMOCORP, c=AU'