Merge "Detect LDAP misconfiguration and fail earlier"

This commit is contained in:
David Pursehouse 2015-09-16 05:54:40 +00:00 committed by Gerrit Code Review
commit ecbaf100a6

View File

@ -163,6 +163,7 @@ public class LdapRealm extends AbstractRealm {
return null;
} else {
checkBackendCompliance(n, v[0], Strings.isNullOrEmpty(d));
return v[0];
}
}
@ -186,6 +187,16 @@ public class LdapRealm extends AbstractRealm {
}
}
private static void checkBackendCompliance(String configOption,
String suppliedValue, boolean disabledByBackend) {
if (disabledByBackend && !Strings.isNullOrEmpty(suppliedValue)) {
String msg = String.format("LDAP backend doesn't support: ldap.%s",
configOption);
log.error(msg);
throw new IllegalArgumentException(msg);
}
}
@Override
public boolean allowsEdit(final Account.FieldName field) {
return !readOnlyAccountFields.contains(field);