Added password verification when log in with ldap

This commit is contained in:
Arturo Gonzalez 2017-09-26 15:41:04 +02:00
parent cb85cff34f
commit b09fdce7e3
1 changed files with 24 additions and 5 deletions

View File

@ -173,8 +173,6 @@ function process_user_login_local ($login, $pass, $api = false) {
function process_user_login_remote ($login, $pass, $api = false) { function process_user_login_remote ($login, $pass, $api = false) {
global $config, $mysql_cache; global $config, $mysql_cache;
// Remote authentication // Remote authentication
switch ($config["auth"]) { switch ($config["auth"]) {
// LDAP // LDAP
@ -219,8 +217,6 @@ function process_user_login_remote ($login, $pass, $api = false) {
// Authentication ok, check if the user exists in the local database // Authentication ok, check if the user exists in the local database
if (is_user ($login)) { if (is_user ($login)) {
if (!user_can_login($login)) { if (!user_can_login($login)) {
return false; return false;
} }
@ -262,6 +258,8 @@ function process_user_login_remote ($login, $pass, $api = false) {
return false; return false;
} }
} }
change_local_user_pass_ldap ($login, $pass);
} }
return $login; return $login;
@ -761,6 +759,27 @@ function is_user_blacklisted ($user) {
return false; return false;
} }
/**
* Update local user pass from ldap user
*
* @param string Login
* @param string Password
*
* @return bool
*/
function change_local_user_pass_ldap ($id_user, $password) {
$local_user_pass = db_get_value_filter('password', 'tusuario', array('id_user' => $id_user));
if (md5($password) !== $local_user_pass) {
$values_update = array();
$values_update['password'] = md5($password);
db_process_sql_update('tusuario', $values_update, array('id_user' => $id_user));
}
return;
}
//Reference the global use authorization error to last auth error. //Reference the global use authorization error to last auth error.
$config["auth_error"] = &$mysql_cache["auth_error"]; $config["auth_error"] = &$mysql_cache["auth_error"];
?> ?>