diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
index 86d012cd1..6ddd16ecc 100644
--- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
+++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
@@ -744,6 +744,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/** The key of the configuration. e.g. true */
String LDAP_ADMIN_SYNC_PASSWORD = "ldap.admin.sync.password";
+ /** The key of the configuration. e.g. -1 */
+ String LDAP_MAX_USERNAME_LENGTH = "ldap.max.username.length";
+
/** The key of the configuration. e.g. memberOf */
String LDAP_MEMBEROF_ATTRIBUTE = "ldap.memberof.attribute";
@@ -3042,6 +3045,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
*/
boolean isLdapAdminSyncPassword();
+ /**
+ * Get the value for the key 'ldap.max.username.length'.
+ * The value is, e.g. -1
+ * @return The value of found property. (NotNull: if not found, exception but basically no way)
+ */
+ String getLdapMaxUsernameLength();
+
+ /**
+ * Get the value for the key 'ldap.max.username.length' as {@link Integer}.
+ * The value is, e.g. -1
+ * @return The value of found property. (NotNull: if not found, exception but basically no way)
+ * @throws NumberFormatException When the property is not integer.
+ */
+ Integer getLdapMaxUsernameLengthAsInteger();
+
/**
* Get the value for the key 'ldap.memberof.attribute'.
* The value is, e.g. memberOf
@@ -4321,6 +4339,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
return is(FessConfig.LDAP_ADMIN_SYNC_PASSWORD);
}
+ public String getLdapMaxUsernameLength() {
+ return get(FessConfig.LDAP_MAX_USERNAME_LENGTH);
+ }
+
+ public Integer getLdapMaxUsernameLengthAsInteger() {
+ return getAsInteger(FessConfig.LDAP_MAX_USERNAME_LENGTH);
+ }
+
public String getLdapMemberofAttribute() {
return get(FessConfig.LDAP_MEMBEROF_ATTRIBUTE);
}
diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java
index 100c52803..0cdc9e417 100644
--- a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java
+++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java
@@ -404,8 +404,19 @@ public interface FessProp {
setSystemProperty(Constants.LDAP_SECURITY_PRINCIPAL, value);
}
+ Integer getLdapMaxUsernameLengthAsInteger();
+
public default String getLdapSecurityPrincipal(final String username) {
- return String.format(getSystemProperty(Constants.LDAP_SECURITY_PRINCIPAL, StringUtil.EMPTY), username);
+ final String value;
+ final int maxLength = getLdapMaxUsernameLengthAsInteger().intValue();
+ if (username == null) {
+ value = StringUtil.EMPTY;
+ } else if (maxLength >= 0 && username.length() > maxLength) {
+ value = username.substring(0, maxLength);
+ } else {
+ value = username;
+ }
+ return String.format(getSystemProperty(Constants.LDAP_SECURITY_PRINCIPAL, StringUtil.EMPTY), value);
}
public default String getLdapSecurityPrincipal() {
diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties
index 913bead80..69c652119 100644
--- a/src/main/resources/fess_config.properties
+++ b/src/main/resources/fess_config.properties
@@ -399,6 +399,7 @@ ldap.admin.group.base.dn=ou\=Group,dc\=fess,dc\=codelibs,dc\=org
ldap.admin.group.object.classes=groupOfNames
ldap.admin.sync.password=true
+ldap.max.username.length=-1
ldap.memberof.attribute=memberOf
#ldap.memberof.attribute=isMemberOf