From 2c73c19bd5340f61a1b160f44964b094d7ad1a1c Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Wed, 15 Sep 2021 18:26:32 +0200 Subject: [PATCH 1/3] fix ldap passw bug with activedirectory Fix to avoid LDAP Error: 53 (Unwilling to perform) on Samba4 AD --- htdocs/core/class/ldap.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 0e8fd3ee7b4..eb4f200f5fd 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -486,6 +486,7 @@ class Ldap // For better compatibility with Samba4 AD if ($this->serverType == "activedirectory") { unset($info['cn']); // To avoid error : Operation not allowed on RDN (Code 67) + $info['unicodePwd'] = mb_convert_encoding("\"".$info['unicodePwd']."\"", "UTF-16LE", "UTF-8"); // To avoid error : LDAP Error: 53 (Unwilling to perform) } $result = @ldap_modify($this->connection, $dn, $info); From 8c1b3efc47aaa8a329e346af434057ddebe740d1 Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Thu, 16 Sep 2021 09:31:00 +0200 Subject: [PATCH 2/3] Avoir Error 19 Constraint Violation (in case of password unchanged) --- htdocs/core/class/ldap.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index eb4f200f5fd..6f12c9ff4ab 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -486,7 +486,11 @@ class Ldap // For better compatibility with Samba4 AD if ($this->serverType == "activedirectory") { unset($info['cn']); // To avoid error : Operation not allowed on RDN (Code 67) - $info['unicodePwd'] = mb_convert_encoding("\"".$info['unicodePwd']."\"", "UTF-16LE", "UTF-8"); // To avoid error : LDAP Error: 53 (Unwilling to perform) + + // To avoid error : LDAP Error: 53 (Unwilling to perform) + if(isset($info['unicodePwd'])){ + $info['unicodePwd'] = mb_convert_encoding("\"".$info['unicodePwd']."\"", "UTF-16LE", "UTF-8"); + } } $result = @ldap_modify($this->connection, $dn, $info); From 9d3b680259122aa020858e3bbcc2dd4e43b3d297 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 16 Sep 2021 07:31:23 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/core/class/ldap.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 6f12c9ff4ab..e2ce33cc45f 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -486,10 +486,10 @@ class Ldap // For better compatibility with Samba4 AD if ($this->serverType == "activedirectory") { unset($info['cn']); // To avoid error : Operation not allowed on RDN (Code 67) - + // To avoid error : LDAP Error: 53 (Unwilling to perform) - if(isset($info['unicodePwd'])){ - $info['unicodePwd'] = mb_convert_encoding("\"".$info['unicodePwd']."\"", "UTF-16LE", "UTF-8"); + if (isset($info['unicodePwd'])) { + $info['unicodePwd'] = mb_convert_encoding("\"".$info['unicodePwd']."\"", "UTF-16LE", "UTF-8"); } } $result = @ldap_modify($this->connection, $dn, $info);