LDAP : start implementing user update function after LDAP connexion
This commit is contained in:
parent
81d5fa87e0
commit
faccc978b4
@ -148,6 +148,8 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
|||||||
// ldap2dolibarr synchronisation
|
// ldap2dolibarr synchronisation
|
||||||
if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')
|
if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')
|
||||||
{
|
{
|
||||||
|
dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
|
||||||
|
|
||||||
// On charge les attributs du user ldap
|
// On charge les attributs du user ldap
|
||||||
if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n";
|
if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n";
|
||||||
$resultFetchLdapUser = $ldap->fetch($login,$userSearchFilter);
|
$resultFetchLdapUser = $ldap->fetch($login,$userSearchFilter);
|
||||||
@ -164,6 +166,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
|||||||
$resultFetchUser=$user->fetch('',$login,$sid);
|
$resultFetchUser=$user->fetch('',$login,$sid);
|
||||||
if ($resultFetchUser > 0)
|
if ($resultFetchUser > 0)
|
||||||
{
|
{
|
||||||
|
dol_syslog("functions_ldap::check_user_password_ldap Sync user found id=".$user->id);
|
||||||
// On verifie si le login a change et on met a jour les attributs dolibarr
|
// On verifie si le login a change et on met a jour les attributs dolibarr
|
||||||
if ($user->login != $ldap->login && $ldap->login)
|
if ($user->login != $ldap->login && $ldap->login)
|
||||||
{
|
{
|
||||||
@ -171,7 +174,8 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
|||||||
$user->update($user);
|
$user->update($user);
|
||||||
// TODO Que faire si update echoue car on update avec un login deja existant.
|
// TODO Que faire si update echoue car on update avec un login deja existant.
|
||||||
}
|
}
|
||||||
//$resultUpdate = $user->update_ldap2dolibarr();
|
|
||||||
|
$resultUpdate = $user->update_ldap2dolibarr($ldap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2072,6 +2072,34 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update user using data from the LDAP
|
||||||
|
* // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?)
|
||||||
|
*/
|
||||||
|
function update_ldap2dolibarr(&$ldapuser) {
|
||||||
|
global $user, $conf;
|
||||||
|
|
||||||
|
$this->firstname=$ldapuser->{$conf->global->LDAP_FIELD_FIRSTNAME};
|
||||||
|
$this->lastname=$ldapuser->{$conf->global->LDAP_FIELD_NAME};
|
||||||
|
$this->login=$ldapuser->{$conf->global->LDAP_FIELD_LOGIN};
|
||||||
|
$this->pass=$ldapuser->{$conf->global->LDAP_FIELD_PASSWORD};
|
||||||
|
$this->pass_indatabase_crypted=$ldapuser->{$conf->global->LDAP_FIELD_PASSWORD_CRYPTED};
|
||||||
|
|
||||||
|
$this->office_phone=$ldapuser->{$conf->global->LDAP_FIELD_PHONE};
|
||||||
|
$this->user_mobile=$ldapuser->{$conf->global->LDAP_FIELD_MOBILE};
|
||||||
|
$this->office_fax=$ldapuser->{$conf->global->LDAP_FIELD_FAX};
|
||||||
|
$this->email=$ldapuser->{$conf->global->LDAP_FIELD_MAIL};
|
||||||
|
$this->ldap_sid=$ldapuser->{$conf->global->LDAP_FIELD_SID};
|
||||||
|
|
||||||
|
$this->job=$ldapuser->{$conf->global->LDAP_FIELD_TITLE};
|
||||||
|
$this->note=$ldapuser->{$conf->global->LDAP_FIELD_DESCRIPTION};
|
||||||
|
|
||||||
|
$result = $this->update($user);
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::update_ldap2dolibarr result=".$result, LOG_DEBUG);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user