Commit bdf5111d authored by Radovan Semancik's avatar Radovan Semancik
Browse files

Support for tolerateMultivalueReduction (experimental)

parent 6485ec62
......@@ -58,6 +58,20 @@ public class LdapConfiguration extends AbstractLdapConfiguration {
* EXPERIMENTAL. Not officially supported. Use at your own risk only.
*/
private String[] languageTagAttributes;
/**
* Normally, when multivalue attribute is used as single-valued attribute then an error is thrown.
* This is the default behavior, as it is much better at detecting errors in the data. However, it
* may be a problem, because throwing hard error may prohibit further attempts to correct the value.
*
* This configuration property changes that behavior. If tolerateMultivalueReduction is set to true,
* then the connector will discard all the extra values. Just one of the values will be kept.
* Connector will try to use the first value. But as LDAP does not guarantee value ordering,
* that value may be quite arbitrary.
*
* EXPERIMENTAL. Not officially supported. Use at your own risk only.
*/
private boolean tolerateMultivalueReduction;
@ConfigurationProperty(order = 100)
public String getLockoutStrategy() {
......@@ -102,7 +116,15 @@ public class LdapConfiguration extends AbstractLdapConfiguration {
public void setLanguageTagAttributes(String[] languageTagAttribute) {
this.languageTagAttributes = languageTagAttribute;
}
@ConfigurationProperty(order = 104)
public boolean isTolerateMultivalueReduction() {
return tolerateMultivalueReduction;
}
public void setTolerateMultivalueReduction(boolean tolerateMultivalueReduction) {
this.tolerateMultivalueReduction = tolerateMultivalueReduction;
}
}
\ No newline at end of file
......@@ -199,6 +199,20 @@ public class LdapSchemaTranslator extends AbstractSchemaTranslator<LdapConfigura
attributeHandler.handle(connection, entry, ldapAttribute, ab);
}
if (ldapAttribute.size() == 0) {
LOG.ok("Empty attribute {0} on {1}", ldapAttribute.getUpId(), entry.getDn());
continue;
}
if (ldapAttribute.size() > 1) {
if (!getConfiguration().isTolerateMultivalueReduction()) {
throw new InvalidAttributeValueException("Multi-valued multi-attributes are not supported, attribute "+ldapAttribute.getUpId()+ " on "+entry.getDn());
} else {
LOG.warn("Reducing multiple values of attribute {0} on {1} to a single value", ldapAttribute.getUpId(), entry.getDn());
ab.setAttributeValueCompleteness(AttributeValueCompleteness.INCOMPLETE);
}
}
Value ldapValue = ldapAttribute.get();
Object connIdValue = toConnIdValue(connIdAttributeName, ldapValue, ldapAttributeNameFromSchema, ldapAttributeType);
......@@ -224,16 +238,6 @@ public class LdapSchemaTranslator extends AbstractSchemaTranslator<LdapConfigura
return null;
}
if (ldapAttribute.size() == 0) {
LOG.ok("Empty attribute {0};{1}", ldapAttribute.getUpId(), option);
return null;
}
if (ldapAttribute.size() > 1) {
throw new InvalidAttributeValueException("Multi-valued multi-attributes are not supported, attribute "+ldapAttribute.getUpId()
+";"+option);
}
if (option == null) {
return POLYSTRING_ORIG_KEY;
} else {
......
......@@ -153,6 +153,9 @@ openLdapAccessLogAdditionalFilter.help=An additional search filter for the delet
languageTagAttributes.display=Language tag attributes
languageTagAttributes.help=Attribute that supports language tag (RFC 3866). EXPERIMENTAL. Not officially supported. Use at your own risk only.
tolerateMultivalueReduction.display=Tolerate multivalue reduction
tolerateMultivalueReduction.help=If tolerateMultivalueReduction is set to true, then the connector will discard all the extra values of multivalue attributes that are reduced to single value. EXPERIMENTAL. Not officially supported. Use at your own risk only.
# AD & eDir
userObjectClass.display=User object class
......
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