From 3cb4556029d07642df8c5b21657602cde118bdb2 Mon Sep 17 00:00:00 2001 From: Skywalker-11 Date: Mon, 5 Mar 2018 13:40:32 +0100 Subject: [PATCH 1/2] enable use of dn field as username --- mailscanner/functions.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mailscanner/functions.php b/mailscanner/functions.php index e62de9891..db561a1aa 100644 --- a/mailscanner/functions.php +++ b/mailscanner/functions.php @@ -2914,13 +2914,19 @@ function ldap_authenticate($username, $password) return null; } - if (!isset($result[0][LDAP_USERNAME_FIELD], $result[0][LDAP_USERNAME_FIELD][0])) { + if (!isset($result[0][LDAP_USERNAME_FIELD])) { @trigger_error(__('ldapno03') . ' "' . LDAP_USERNAME_FIELD . '" ' . __('ldapresults03')); - return null; } + if (!is_array($result[0][LDAP_USERNAME_FIELD])) { + $user = $result[0][LDAP_USERNAME_FIELD]; + } elseif (isset($result[0][LDAP_USERNAME_FIELD][0])) { + $user = $result[0][LDAP_USERNAME_FIELD][0]; + } else { + @trigger_error(__('ldapno03') . ' "' . LDAP_USERNAME_FIELD . '" ' . __('ldapresults03')); + return null; + } - $user = $result[0][LDAP_USERNAME_FIELD][0]; if (defined('LDAP_BIND_PREFIX')) { $user = LDAP_BIND_PREFIX . $user; } From b45b4e67187dec6324f9c8108576b42ab06107db Mon Sep 17 00:00:00 2001 From: Skywalker-11 Date: Mon, 5 Mar 2018 14:03:24 +0100 Subject: [PATCH 2/2] fix style --- mailscanner/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mailscanner/functions.php b/mailscanner/functions.php index db561a1aa..984294824 100644 --- a/mailscanner/functions.php +++ b/mailscanner/functions.php @@ -2923,8 +2923,8 @@ function ldap_authenticate($username, $password) } elseif (isset($result[0][LDAP_USERNAME_FIELD][0])) { $user = $result[0][LDAP_USERNAME_FIELD][0]; } else { - @trigger_error(__('ldapno03') . ' "' . LDAP_USERNAME_FIELD . '" ' . __('ldapresults03')); - return null; + @trigger_error(__('ldapno03') . ' "' . LDAP_USERNAME_FIELD . '" ' . __('ldapresults03')); + return null; } if (defined('LDAP_BIND_PREFIX')) {