Commit 8fc0434b 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 d80ba190
......@@ -856,7 +856,7 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
AttributeType ldapAttrType = shcemaTranslator.toLdapAttribute(ldapStructuralObjectClass, icfAttr.getName());
List<Value> ldapValues = shcemaTranslator.toLdapValues(ldapAttrType, icfAttr.getValue());
// Do NOT set attributeType here. The attributeType may not match the type of the value.
entry.put(ldapAttrType.getName(), ldapValues.toArray(new Value[ldapValues.size()]));
entry.put(icfAttr.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.
}
......@@ -1107,7 +1107,7 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
}
private void addLdapModification(List<Modification> ldapModifications,
ModificationOperation modOp, AttributeType ldapAttributeType, List<Object> values) {
ModificationOperation modOp, String nativeName, AttributeType ldapAttributeType, List<Object> values) {
if (values == null) {
return;
}
......@@ -1116,12 +1116,12 @@ public abstract class AbstractLdapConnector<C extends AbstractLdapConfiguration>
// 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));
}
}
......@@ -1180,9 +1180,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(modifications, ModificationOperation.REPLACE_ATTRIBUTE, ldapAttributeType, delta.getValuesToReplace());
addLdapModification(modifications, ModificationOperation.ADD_ATTRIBUTE, ldapAttributeType, delta.getValuesToAdd());
addLdapModification(modifications, ModificationOperation.REMOVE_ATTRIBUTE, ldapAttributeType, delta.getValuesToRemove());
addLdapModification(modifications, ModificationOperation.REPLACE_ATTRIBUTE, delta.getName(), ldapAttributeType, delta.getValuesToReplace());
addLdapModification(modifications, ModificationOperation.ADD_ATTRIBUTE, delta.getName(), ldapAttributeType, delta.getValuesToAdd());
addLdapModification(modifications, ModificationOperation.REMOVE_ATTRIBUTE, delta.getName(), ldapAttributeType, delta.getValuesToRemove());
}
protected void postUpdate(ObjectClass connIdObjectClass, Uid uid, Set<AttributeDelta> deltas,
......
......@@ -1341,6 +1341,10 @@ public abstract class AbstractSchemaTranslator<C extends AbstractLdapConfigurati
}
} else {
ldapAttributeNameFromSchema = ldapAttributeType.getName();
// handle attribute options
String[] a = ldapAttributeName.split(";", 2);
if (a.length > 1)
ldapAttributeNameFromSchema = ldapAttributeNameFromSchema + ";" + a[1];
}
String icfAttributeName = toConnIdAttributeName(ldapAttributeNameFromSchema);
ab.setName(icfAttributeName);
......
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