From abc3aa8a0eb0dec01783627296092a2eb600382f Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Mon, 19 Sep 2011 09:35:20 -0400 Subject: [PATCH] - Set group_bind_dn outside of list_groups() --- program/include/rcube_ldap.php | 40 +++++++++++++++------------------------- 1 files changed, 15 insertions(+), 25 deletions(-) diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php index 48920d9..870f3e9 100644 --- a/program/include/rcube_ldap.php +++ b/program/include/rcube_ldap.php @@ -173,7 +173,10 @@ $bind_pass = $this->prop['bind_pass']; $bind_user = $this->prop['bind_user']; $bind_dn = $this->prop['bind_dn']; - $this->base_dn = $this->prop['base_dn']; + + $this->base_dn = $this->prop['base_dn']; + $this->groups_base_dn = ($this->prop['groups']['base_dn']) ? + $this->prop['groups']['base_dn'] : $this->base_dn; // User specific access, generate the proper values to use. if ($this->prop['user_specific']) { @@ -199,7 +202,7 @@ $this->_debug("S: searching with base {$this->prop['search_base_dn']} for {$this->prop['search_filter']}"); - $res = ldap_search($this->conn, $this->prop['search_base_dn'], $this->prop['search_filter'], array('uid')); + $res = @ldap_search($this->conn, $this->prop['search_base_dn'], $this->prop['search_filter'], array('uid')); if ($res && ($entry = ldap_first_entry($this->conn, $res))) { $bind_dn = ldap_get_dn($this->conn, $entry); @@ -212,8 +215,9 @@ } } // Replace the bind_dn and base_dn variables. - $bind_dn = strtr($bind_dn, $replaces); - $this->base_dn = strtr($this->base_dn, $replaces); + $bind_dn = strtr($bind_dn, $replaces); + $this->base_dn = strtr($this->base_dn, $replaces); + $this->groups_base_dn = strtr($this->groups_base_dn, $replaces); if (empty($bind_user)) { $bind_user = $u; @@ -222,13 +226,13 @@ if (!empty($bind_pass)) { if (!empty($bind_dn)) { - $this->ready = $this->_bind($bind_dn, $bind_pass); + $this->ready = $this->bind($bind_dn, $bind_pass); } else if (!empty($this->prop['auth_cid'])) { - $this->ready = $this->_sasl_bind($this->prop['auth_cid'], $bind_pass, $bind_user); + $this->ready = $this->sasl_bind($this->prop['auth_cid'], $bind_pass, $bind_user); } else { - $this->ready = $this->_sasl_bind($bind_user, $bind_pass); + $this->ready = $this->sasl_bind($bind_user, $bind_pass); } } } @@ -253,7 +257,7 @@ * * @return boolean True on success, False on error */ - private function _sasl_bind($authc, $pass, $authz=null) + public function sasl_bind($authc, $pass, $authz=null) { if (!$this->conn) { return false; @@ -304,7 +308,7 @@ * * @return boolean True on success, False on error */ - private function _bind($dn, $pass) + public function bind($dn, $pass) { if (!$this->conn) { return false; @@ -1096,26 +1100,12 @@ if (!$this->groups) return array(); - $this->groups_base_dn = ($this->prop['groups']['base_dn']) ? - $this->prop['groups']['base_dn'] : $this->base_dn; - - // replace user specific dn - if ($this->prop['user_specific']) - { - $fu = $RCMAIL->user->get_username(); - list($u, $d) = explode('@', $fu); - $dc = 'dc='.strtr($d, array('.' => ',dc=')); - $replaces = array('%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u); - - $this->groups_base_dn = strtr($this->groups_base_dn, $replaces); - } - $base_dn = $this->groups_base_dn; $filter = $this->prop['groups']['filter']; $this->_debug("C: Search [$filter][dn: $base_dn]"); - $res = ldap_search($this->conn, $base_dn, $filter, array('cn','member')); + $res = @ldap_search($this->conn, $base_dn, $filter, array('cn','member')); if ($res === false) { $this->_debug("S: ".ldap_error($this->conn)); @@ -1335,7 +1325,7 @@ $this->_debug("C: Search [$filter][dn: $base_dn]"); - $res = ldap_search($this->conn, $base_dn, $filter, array('cn')); + $res = @ldap_search($this->conn, $base_dn, $filter, array('cn')); if ($res === false) { $this->_debug("S: ".ldap_error($this->conn)); -- Gitblit v1.9.1