fixed an issue with ldap_sync in case of the users DN is changed

This commit is contained in:
SJ 2012-09-13 23:47:04 +02:00
parent e688ce0420
commit ca689e4b30
2 changed files with 21 additions and 0 deletions

View File

@ -211,6 +211,13 @@ class ModelUserImport extends Model {
}
else {
/* update DN field if it's an existing user */
if(($cuid = $this->model_user_user->get_uid_by_name($_user['username'])) > 0) {
$this->model_user_user->update_dn_by_uid($cuid, $_user['dn']);
continue;
}
/* or add the new user */
$user = $this->createNewUserArray($_user['dn'], $_user['username'], $_user['realname'], $_user['emails'], $globals);

View File

@ -445,6 +445,20 @@ class ModelUserUser extends Model {
}
public function update_dn_by_uid($uid = 0, $new_dn = '') {
if(!$this->check_uid($uid) || $new_dn == ''){ return 0; }
$user = $this->get_user_by_uid($uid);
if(isset($user['uid']) && $user['dn'] != '' && $user['dn'] != '*') {
$query = $this->db->query("UPDATE " . TABLE_USER . " SET dn=? WHERE uid=?", array($new_dn, $uid));
return 1;
}
return 0;
}
public function delete_user($uid) {
if(!$this->check_uid($uid)){ return 0; }