summaryrefslogtreecommitdiffstats
path: root/lib/Auth
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-11-27 10:34:52 +0100
committerAleksander Machniak <alec@alec.pl>2013-11-27 10:34:52 +0100
commit1d2c64307205709c5cdd7df85fa51dd1fc540b69 (patch)
treebd76bce20f6a1826796cb1e1c691fe2d7c3cf4be /lib/Auth
parent00d43c3f2ef02f1c2188e5dd96cb255cac8268a1 (diff)
downloadwebadmin-1d2c64307205709c5cdd7df85fa51dd1fc540b69.tar.gz
Fix email address comparissons, so local part is case-sensitive, but domain part is not
Diffstat (limited to 'lib/Auth')
-rw-r--r--lib/Auth/LDAP.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 7de9017..25cb754 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -593,6 +593,10 @@ class LDAP extends Net_LDAP3 {
public function find_recipient($address)
{
+ if (strpos($address, '@') === false) {
+ return false;
+ }
+
$this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
$mail_attrs = $this->conf->get_list('mail_attributes') ?: array('mail', 'alias');
@@ -610,10 +614,28 @@ class LDAP extends Net_LDAP3 {
$result = $this->search_entries($this->config_get('root_dn'), '(objectclass=*)', 'sub', null, $search);
if ($result && $result->count() > 0) {
- return $result->entries(TRUE);
+ $result = $result->entries(true);
+
+ // LDAP searches are case-insensitive, post-process result
+ // with correct character case handling
+ foreach ($result as $key => $user) {
+ foreach ($user as $attr => $list) {
+ foreach ((array) $list as $addr) {
+ if (compare_email($address, $addr)) {
+ continue 3;
+ }
+ }
+ }
+
+ unset($result[$key]);
+ }
+
+ reset($result);
+
+ return $result;
}
- return FALSE;
+ return false;
}
public function get_attributes($subject_dn, $attributes)