Thomas Bruederli
2014-06-05 99cdca46b7bcc46fe6affd9e9f9f60a546b2e5b8
program/lib/Roundcube/rcube_ldap_generic.php
@@ -160,7 +160,7 @@
                $this->config['hosts'] = array($this->config['hosts']);
            foreach ($this->config['hosts'] as $host) {
                if ($this->connect($host)) {
                if (!empty($host) && $this->connect($host)) {
                    return true;
                }
            }
@@ -190,6 +190,9 @@
            if (isset($this->config['referrals']))
                ldap_set_option($lc, LDAP_OPT_REFERRALS, $this->config['referrals']);
            if (isset($this->config['dereference']))
                ldap_set_option($lc, LDAP_OPT_DEREF, $this->config['dereference']);
        }
        else {
            $this->_debug("S: NOT OK");
@@ -240,7 +243,7 @@
            $method = 'DIGEST-MD5';
        }
        $this->_debug("C: SASL Bind [mech: $method, authc: $authc, authz: $authz, pass: $pass]");
        $this->_debug("C: SASL Bind [mech: $method, authc: $authc, authz: $authz, pass: **** [" . strlen($pass) . "]");
        if (ldap_sasl_bind($this->conn, NULL, $pass, $method, NULL, $authc, $authz)) {
            $this->_debug("S: OK");
@@ -271,7 +274,7 @@
            return false;
        }
        $this->_debug("C: Bind $dn [pass: $pass]");
        $this->_debug("C: Bind $dn, pass: **** [" . strlen($pass) . "]");
        if (@ldap_bind($this->conn, $dn, $pass)) {
            $this->_debug("S: OK");
@@ -696,11 +699,17 @@
     * Turn an LDAP entry into a regular PHP array with attributes as keys.
     *
     * @param array $entry Attributes array as retrieved from ldap_get_attributes() or ldap_get_entries()
     *
     * @return array       Hash array with attributes as keys
     */
    public static function normalize_entry($entry)
    {
        if (!isset($entry['count'])) {
            return $entry;
        }
        $rec = array();
        for ($i=0; $i < $entry['count']; $i++) {
            $attr = $entry[$i];
            if ($entry[$attr]['count'] == 1) {
@@ -880,9 +889,10 @@
        }
        $this->vlv_config = array();
        $config_root_dn = $this->config['config_root_dn'];
        $ldap_result = ldap_search($this->conn, $this->config['config_root_dn'], '(objectclass=vlvsearch)', array('*'), 0, 0, 0);
        $vlv_searches = new rcube_ldap_result($this->conn, $ldap_result, $this->config['config_root_dn'], '(objectclass=vlvsearch)');
        $ldap_result = ldap_search($this->conn, $config_root_dn, '(objectclass=vlvsearch)', array('*'), 0, 0, 0);
        $vlv_searches = new rcube_ldap_result($this->conn, $ldap_result, $config_root_dn, '(objectclass=vlvsearch)');
        if ($vlv_searches->count() < 1) {
            $this->_debug("D: Empty result from search for '(objectclass=vlvsearch)' on '$config_root_dn'");