From 0f63418b7e3143f274718a7adeabe5ac1d54be29 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 29 Apr 2015 08:02:23 -0400
Subject: [PATCH] Use Net_LDAP3::domain_root_dn() to resolve the domain DN for the %dc variable; replaces PR #268
---
program/lib/Roundcube/rcube_ldap.php | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php
index f492111..dc7b3c0 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -283,13 +283,22 @@
}
// Get the pieces needed for variable replacement.
- if ($fu = $rcube->get_user_email())
+ if ($fu = $rcube->get_user_email()) {
list($u, $d) = explode('@', $fu);
- else
+ }
+ else {
$d = $this->mail_domain;
+ }
$dc = 'dc='.strtr($d, array('.' => ',dc=')); // hierarchal domain string
+ // resolve $dc through LDAP
+ if (!empty($this->prop['domain_filter']) && !empty($this->prop['search_bind_dn']) &&
+ method_exists($this->ldap, 'domain_root_dn')) {
+ $this->ldap->bind($this->prop['search_bind_dn'], $this->prop['search_bind_pw']);
+ $dc = $this->ldap->domain_root_dn($d);
+ }
+
$replaces = array('%dn' => '', '%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u);
// Search for the dn to use to authenticate
--
Gitblit v1.9.1