Jelajahi Sumber

add appproperty for ldap cluster attr

jrivard@gmail.com 6 tahun lalu
induk
melakukan
351f4bb20b

+ 1 - 0
server/src/main/java/password/pwm/AppProperty.java

@@ -83,6 +83,7 @@ public enum AppProperty
     CLUSTER_DB_HEARTBEAT_SECONDS                    ( "cluster.db.heartbeatSeconds" ),
     CLUSTER_DB_NODE_TIMEOUT_SECONDS                 ( "cluster.db.nodeTimeoutSeconds" ),
     CLUSTER_DB_NODE_PURGE_SECONDS                   ( "cluster.db.nodePurgeSeconds" ),
+    CLUSTER_LDAP_ATTRIBUTES                         ( "cluster.ldap.attribute" ),
     CLUSTER_LDAP_HEARTBEAT_SECONDS                  ( "cluster.ldap.heartbeatSeconds" ),
     CLUSTER_LDAP_NODE_TIMEOUT_SECONDS               ( "cluster.ldap.nodeTimeoutSeconds" ),
     CLUSTER_LDAP_NODE_PURGE_SECONDS                 ( "cluster.ldap.nodePurgeSeconds" ),

+ 13 - 1
server/src/main/java/password/pwm/svc/cluster/LDAPClusterDataService.java

@@ -25,6 +25,7 @@ package password.pwm.svc.cluster;
 import com.novell.ldapchai.ChaiUser;
 import com.novell.ldapchai.exception.ChaiException;
 import lombok.Value;
+import password.pwm.AppProperty;
 import password.pwm.PwmApplication;
 import password.pwm.bean.UserIdentity;
 import password.pwm.config.PwmSetting;
@@ -32,6 +33,7 @@ import password.pwm.error.ErrorInformation;
 import password.pwm.error.PwmError;
 import password.pwm.error.PwmUnrecoverableException;
 import password.pwm.util.java.JsonUtil;
+import password.pwm.util.java.StringUtil;
 import password.pwm.util.java.TimeDuration;
 import password.pwm.util.logging.PwmLogger;
 
@@ -158,6 +160,7 @@ public class LDAPClusterDataService implements ClusterDataServiceProvider
             this.pwmApplication = pwmApplication;
 
             userIdentity = pwmApplication.getConfig().getDefaultLdapProfile().getTestUser( pwmApplication );
+
             if ( userIdentity == null )
             {
                 final String ldapProfileID = pwmApplication.getConfig().getDefaultLdapProfile().getIdentifier();
@@ -165,8 +168,17 @@ public class LDAPClusterDataService implements ClusterDataServiceProvider
                 final ErrorInformation errorInformation = new ErrorInformation( PwmError.CONFIG_FORMAT_ERROR, errorMsg );
                 throw new PwmUnrecoverableException( errorInformation );
             }
+
             chaiUser = pwmApplication.getProxiedChaiUser( userIdentity );
-            attr = userIdentity.getLdapProfile( pwmApplication.getConfig() ).readSettingAsString( PwmSetting.CHALLENGE_USER_ATTRIBUTE );
+
+            {
+                String ldapAttribute = pwmApplication.getConfig().readAppProperty( AppProperty.CLUSTER_LDAP_ATTRIBUTES );
+                if ( StringUtil.isEmpty( ldapAttribute ) )
+                {
+                    ldapAttribute = userIdentity.getLdapProfile( pwmApplication.getConfig() ).readSettingAsString( PwmSetting.CHALLENGE_USER_ATTRIBUTE );
+                }
+                attr = ldapAttribute;
+            }
 
         }
 

+ 1 - 0
server/src/main/resources/password/pwm/AppProperty.properties

@@ -60,6 +60,7 @@ cluster.db.enable=true
 cluster.db.heartbeatSeconds=60
 cluster.db.nodeTimeoutSeconds=600
 cluster.db.nodePurgeSeconds=86400
+cluster.ldap.attribute=
 cluster.ldap.heartbeatSeconds=60
 cluster.ldap.nodeTimeoutSeconds=600
 cluster.ldap.nodePurgeSeconds=86400