Permalink
Browse files

MDL-32724: LDAP Auth function user_update() returns true even if upda…

…te has failed
  • Loading branch information...
1 parent 4f6e4f8 commit b1f5a038f3e627191833a6b9f277c9312fe37ecb @iarenaza iarenaza committed Feb 4, 2014
Showing with 8 additions and 3 deletions.
  1. +8 −3 auth/ldap/auth.php
View
@@ -1179,6 +1179,7 @@ function user_update($olduser, $newuser) {
return false;
}
+ $success = true;
$user_info_result = ldap_read($ldapconnection, $user_dn, '(objectClass=*)', $search_attribs);
if ($user_info_result) {
$user_entry = ldap_get_entries_moodle($ldapconnection, $user_info_result);
@@ -1233,8 +1234,10 @@ function user_update($olduser, $newuser) {
if ($nuvalue !== $ldapvalue) {
// This might fail due to schema validation
if (@ldap_modify($ldapconnection, $user_dn, array($ldapkey => $nuvalue))) {
+ $changed = true;
continue;
} else {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfail', 'auth_ldap',
array('errno'=>ldap_errno($ldapconnection),
'errstring'=>ldap_err2str(ldap_errno($ldapconnection)),
@@ -1253,6 +1256,7 @@ function user_update($olduser, $newuser) {
$changed = true;
continue;
} else {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfail', 'auth_ldap',
array('errno'=>ldap_errno($ldapconnection),
'errstring'=>ldap_err2str(ldap_errno($ldapconnection)),
@@ -1270,6 +1274,7 @@ function user_update($olduser, $newuser) {
$changed = true;
continue;
} else {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfail', 'auth_ldap',
array('errno'=>ldap_errno($ldapconnection),
'errstring'=>ldap_err2str(ldap_errno($ldapconnection)),
@@ -1283,6 +1288,7 @@ function user_update($olduser, $newuser) {
}
if ($ambiguous and !$changed) {
+ $success = false;
error_log($this->errorlogtag.get_string ('updateremfailamb', 'auth_ldap',
array('key'=>$key,
'ouvalue'=>$ouvalue,
@@ -1292,12 +1298,11 @@ function user_update($olduser, $newuser) {
}
} else {
error_log($this->errorlogtag.get_string ('usernotfound', 'auth_ldap'));
- $this->ldap_close();
- return false;
+ $success = false;
}
$this->ldap_close();
- return true;
+ return $success;
}

0 comments on commit b1f5a03

Please sign in to comment.