diff --git a/inc/Principal.php b/inc/Principal.php index f0fc3596..fa78aeee 100644 --- a/inc/Principal.php +++ b/inc/Principal.php @@ -319,7 +319,7 @@ class Principal { * @return string The username */ function setUsername($new_username) { - if ( $this->exists ) return false; + if ( $this->exists && isset($this->username) ) return false; $this->username = $new_username; return $this->username; } diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index 895a2311..1fe7033e 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -346,9 +346,9 @@ function LDAP_check($username, $password ){ } else { dbg_error_log( "LDAP", "user %s doesn't exist in local DB, we need to create it",$username ); - $principal->setUsername($username ); } - + $principal->setUsername($username); + // The local cached user doesn't exist, or is older, so we create/update their details sync_user_from_LDAP( $principal, $mapping, $valid );