Commit 25067e61 authored by Ing. František DVOŘÁK's avatar Ing. František DVOŘÁK
Browse files

Support for LDAP attribute options in search, create, and modify operations

parent bba16ee5
......@@ -866,7 +866,7 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
} else {
List<Value> ldapValues = shcemaTranslator.toLdapValues(ldapAttributeType, connIdAttrValues);
// Do NOT set attributeType here. The attributeType may not match the type of the value.
entry.put(ldapAttributeType.getName(), ldapValues.toArray(new Value[ldapValues.size()]));
entry.put(connIdAttr.getName(), ldapValues.toArray(new Value[ldapValues.size()]));
// no simple way how to check if he attribute was added. It may end up with ERR_04451. So let's just
// hope that it worked well. It should - unless there is a connector bug.
}
......@@ -1159,9 +1159,9 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
&& !ArrayUtils.contains(configuration.getOperationalAttributes(), delta.getName())) {
throw new InvalidAttributeValueException("Unknown attribute "+delta.getName()+" in object class "+connIdObjectClass);
}
addLdapModification(dn, modifications, ModificationOperation.REPLACE_ATTRIBUTE, ldapAttributeType, delta.getValuesToReplace());
addLdapModification(dn, modifications, ModificationOperation.ADD_ATTRIBUTE, ldapAttributeType, delta.getValuesToAdd());
addLdapModification(dn, modifications, ModificationOperation.REMOVE_ATTRIBUTE, ldapAttributeType, delta.getValuesToRemove());
addLdapModification(dn, modifications, ModificationOperation.REPLACE_ATTRIBUTE, delta.getName(), ldapAttributeType, delta.getValuesToReplace());
addLdapModification(dn, modifications, ModificationOperation.ADD_ATTRIBUTE, delta.getName(), ldapAttributeType, delta.getValuesToAdd());
addLdapModification(dn, modifications, ModificationOperation.REMOVE_ATTRIBUTE, delta.getName(), ldapAttributeType, delta.getValuesToRemove());
}
private void addLdapModificationString(List<Modification> ldapModifications,
......@@ -1180,7 +1180,7 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
}
private void addLdapModification(Dn dn, List<Modification> ldapModifications,
ModificationOperation modOp, AttributeType ldapAttributeType, List<Object> connIdValues) {
ModificationOperation modOp, String nativeName, AttributeType ldapAttributeType, List<Object> connIdValues) {
if (connIdValues == null) {
return;
}
......@@ -1188,7 +1188,7 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
if (schemaTranslator.isPolyAttribute(ldapAttributeType, connIdValues)) {
addLdapModificationPoly(dn, ldapModifications, modOp, ldapAttributeType, connIdValues);
} else {
addLdapModificationSimple(dn, ldapModifications, modOp, ldapAttributeType, connIdValues);
addLdapModificationSimple(dn, ldapModifications, modOp, nativeName, ldapAttributeType, connIdValues);
}
}
......@@ -1196,18 +1196,18 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
* For simple (non-poly) attributes. The usual stuff. Used for most cases.
*/
private void addLdapModificationSimple(Dn dn, List<Modification> ldapModifications,
ModificationOperation modOp, AttributeType ldapAttributeType, List<Object> connIdValues) {
ModificationOperation modOp, String nativeName, AttributeType ldapAttributeType, List<Object> connIdValues) {
List<Value> ldapValues = schemaTranslator.toLdapValues(ldapAttributeType, connIdValues);
if (ldapValues == null || ldapValues.isEmpty()) {
// Do NOT set AttributeType here
// The attributeType might not match the Value class
// e.g. human-readable jpegPhoto attribute will expect StringValue
ldapModifications.add(new DefaultModification(modOp, ldapAttributeType.getName()));
ldapModifications.add(new DefaultModification(modOp, nativeName));
} else {
// Do NOT set AttributeType here
// The attributeType might not match the Value class
// e.g. human-readable jpegPhoto attribute will expect StringValue
DefaultAttribute ldapAttribute = new DefaultAttribute(ldapAttributeType.getName(), ldapValues.toArray(new Value[ldapValues.size()]));
DefaultAttribute ldapAttribute = new DefaultAttribute(nativeName, ldapValues.toArray(new Value[ldapValues.size()]));
ldapModifications.add(new DefaultModification(modOp, ldapAttribute));
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment