From 308619b694a1e2b381fcdd88c1600c2e340dfdfb Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Tue, 10 Sep 2019 23:11:23 +0200 Subject: [PATCH] Fix bug when updating aliases : - array index for LDAP need to be in lowercase - we need also array_filter() for mailacceptinggeneralid... especially to avoid null values - array numeric indexes for LDAP attributes need to be consecutive, then we need order with array_values() --- htdocs/lib/LdapAlias.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/lib/LdapAlias.php b/htdocs/lib/LdapAlias.php index 884a195..3adf50d 100644 --- a/htdocs/lib/LdapAlias.php +++ b/htdocs/lib/LdapAlias.php @@ -28,11 +28,13 @@ class LdapAlias extends LdapDomain { } public function update($active=false,$mailaccept=array(),$maildrop=array()) { - $info["isActive"] = ($active) ? 'TRUE' : 'FALSE'; - $info["mailacceptinggeneralid"] = $mailaccept; - $info["maildrop"] = array_filter($maildrop, function($value) { + $info["isactive"] = ($active) ? 'TRUE' : 'FALSE'; + $info["mailacceptinggeneralid"] = array_values(array_filter($mailaccept, function($value) { return filter_var($value, FILTER_VALIDATE_EMAIL); - }); + })); + $info["maildrop"] = array_values(array_filter($maildrop, function($value) { + return filter_var($value, FILTER_VALIDATE_EMAIL); + })); if (!@ldap_mod_replace($this->conn, self::getBaseDN($this), $info)) { $error = ldap_error($this->conn);