-
Notifications
You must be signed in to change notification settings - Fork 488
Description
Krzysztof Pado (Migrated from LDAP-343) said:
addAttributeValue
method of DirContextAdapter
fails with "java.lang.IllegalArgumentException: This instance has non-string attribute values; cannot handle Name values" when value of Name type is passed as value parameter, if previously another Name value was added.
The following code fails at line 3:
{{1: DirContextOperations operations = new DirContextAdapter("CN=group,DC=root");
2: operations.addAttributeValue("member", LdapUtils.newLdapName("CN=test,DC=root"));
3: operations.addAttributeValue("member", LdapUtils.newLdapName("CN=test2,DC=root"));}}
However, when first attribute is set as string, not as Name it runs fine:
{{1: DirContextOperations operations = new DirContextAdapter("CN=group,DC=root");
2: operations.addAttributeValue("member", "CN=test,DC=root");
3: operations.addAttributeValue("member", LdapUtils.newLdapName("CN=test2,DC=root"));}}
Technical analysis:
In NameAwareAttribute(String id, Object value)
constructor value is added to values
field, but there is no check whether value is instance of a Name, and initValuesAsNames
method is not called. This causes an error in next public boolean add(Object attrVal)
invocation with attrVal of type Name.