From bfeed40b5ec3bd3f2d8e26633e0d11d5b14843ba Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <machniak@kolabsys.com>
Date: Tue, 9 Apr 2019 10:30:08 +0200
Subject: [PATCH] Use config_root_dn => cn=config as a default

Roundcube does not set this value. Unset option didn't allow to
detect vlv indexes.
Also changed the way options are handled in constructor. I saw no
reason why they should not override already set options.
---
 lib/Net/LDAP3.php | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index 2bba0f9..9cdb48c 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -85,8 +85,9 @@ class Net_LDAP3
      *       'root_dn'         => 'dc=example,dc=org',
      */
     protected $config = array(
-        'sizelimit' => 0,
-        'timelimit' => 0,
+        'sizelimit'      => 0,
+        'timelimit'      => 0,
+        'config_root_dn' => 'cn=config',
     );
 
     protected $debug_level = false;
@@ -122,26 +123,22 @@ class Net_LDAP3
     /**
      * Constructor
      *
-     * @param array $config Configuration parameters that have not already
-     *                      been initialized. For configuration parameters
-     *                      that have in fact been set, use the config_set()
-     *                      method after initialization.
+     * @param array $config Configuration parameters. After initialization use
+     *                      the config_set() method.
      */
     public function __construct($config = array())
     {
         if (!empty($config) && is_array($config)) {
             foreach ($config as $key => $value) {
-                if (empty($this->config[$key])) {
-                    $setter = 'config_set_' . $key;
-                    if (method_exists($this, $setter)) {
-                        $this->$setter($value);
-                    }
-                    else if (isset($this->$key)) {
-                        $this->$key = $value;
-                    }
-                    else {
-                        $this->config[$key] = $value;
-                    }
+                $setter = 'config_set_' . $key;
+                if (method_exists($this, $setter)) {
+                    $this->$setter($value);
+                }
+                else if (isset($this->$key)) {
+                    $this->$key = $value;
+                }
+                else {
+                    $this->config[$key] = $value;
                 }
             }
         }
-- 
GitLab