LSldap::updateUserPassword(): fix handling non-ppolicy errors

This commit is contained in:
Benjamin Renard 2024-11-13 11:16:29 +01:00
parent 0e705852af
commit 4057300ba0
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -849,20 +849,22 @@ class LSldap extends LSlog_staticLoggerClass {
$ctrlRequest = array(array('oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST));
$r = ldap_mod_replace_ext($ldap, $dn, $changes, $ctrlRequest);
if ($r && ldap_parse_result($ldap, $r, $errcode, $matcheddn, $errmsg, $ref, $ctrlResponse)) {
if ($errcode !== 0 && isset($ctrlResponse[LDAP_CONTROL_PASSWORDPOLICYRESPONSE])) {
if ($errcode !== 0) {
$error = (
isset($ctrlResponse[LDAP_CONTROL_PASSWORDPOLICYRESPONSE])?
$ppolicyErrorMsg[
$ctrlResponse[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error']
]:
_("Unknown error")
);
self :: fireEvent(
'user_password_update_failure',
array(
'object_type' => $object_type, 'dn' => $dn,
'error' => $ppolicyErrorMsg[
$ctrlResponse[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error']
]
'error' => $error,
)
);
LSerror :: addErrorCode(
'LSldap_10',
$ppolicyErrorMsg[$ctrlResponse[LDAP_CONTROL_PASSWORDPOLICYRESPONSE]['value']['error']]
);
LSerror :: addErrorCode('LSldap_10', $error);
return false;
}
// Password updated