This diff for rcube_ldap.php allows users to define an array 'search_base_dn' in an ldap config. This is for users that may have to deal with poor LDAP data (like you would see from someone who can install Windows Server 2008 so they think they're an IT admin expert).
I freely and openly admit that I am NOT an expert programmer (or expert anything really). This patch "worked for me" for my specific implementation. It shouldn't break anything for people with a single search base defined in 'base_dn'.
Example: .... // regular ldap configuration options 'search_base_dn' => array( 'OU=Administration,DC=company,DC=org', 'OU=Finance,DC=company,DC=org'), .... // continue regular ldap options
Note that the diff results below are against the rcube_ldap.php in 0.3b.
TA
55,56d54 < if (! isset($this->prop['search_base_dn'])) < $this->prop['search_base_dn'] = $p['base_dn']; 259a258,260
if ($this->sort_col && $this->prop['scope'] !== "base") @ldap_sort($this->conn, $this->ldap_result, $this->sort_col);
264,280c265 < $entries = array(); < $entries['count'] = 0; < if (is_array($this->ldap_result)) { < // merge multiple ldap results into a single array < foreach ($this->ldap_result as $ldr) { < $single_result_entries = ldap_get_entries($this->conn, $ldr); < for ($srindex=0; $srindex < $single_result_entries['count']; $srindex++) { < $entries[] = $single_result_entries[$srindex]; < $entries['count']++; < } < } < } else { < $entries = ldap_get_entries($this->conn, $this->ldap_result); < } < uasort($entries, array($this, 'sort_entries')); < // array_merge will reindex the array after it is sorted by uasort
$entries = ldap_get_entries($this->conn, $this->ldap_result);
288,292d272 < // this is used by uasort to sort the merged ldap results < function sort_entries($a, $b) { < return (strcmp ($a[$this->sort_col][0],$b[$this->sort_col][0])); < } < 363,370c343 < if (is_array($this->ldap_result)) { < // sum counts for all ldap results < foreach ($this->ldap_result as $ldr) { < $count += ldap_count_entries($this->conn, $ldr); < } < } else { < $count = ldap_count_entries($this->conn, $this->ldap_result);
$count = ldap_count_entries($this->conn, $this->ldap_result);
380,387c353 < if (is_array($this->ldap_result)) { < // sum counts for all ldap results < foreach ($this->ldap_result as $ldr) { < $count += ldap_count_entries($this->conn, $ldr); < } < } else { < $count = ldap_count_entries($this->conn, $this->ldap_result);
$count = ldap_count_entries($this->conn, $this->ldap_result);
580d545 < if ($this->filter == $this->prop['filter']) return false; 583,591d547 < if (is_array($this->prop['search_base_dn'])) { < $conns = array(); < $bdindex = 0; < foreach ($this->prop['search_base_dn'] as $basednval) { < $conns[$bdindex++]=$this->conn; < } < } else { < $conns = $this->conn; < } 593c549 < $this->ldap_result = $function($conns, $this->prop['search_base_dn'], $this->filter, array_values($this->fieldmap), 0, 0);
$this->ldap_result = $function($this->conn,
$this->prop['base_dn'], $this->filter, array_values($this->fieldmap), 0, 0); 640a597
List info: http://lists.roundcube.net/dev/