summaryrefslogtreecommitdiff
path: root/plugins/kolab_auth
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2013-12-10 10:41:24 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2013-12-10 10:41:24 (GMT)
commit94339e0e4bebf93fac56aec41232439f2fbb5841 (patch)
tree5f227e47ab4214e0849b80582f89764dd78c19e1 /plugins/kolab_auth
parentbf028bb53fc508ad29100757384bed293001c122 (diff)
downloadroundcubemail-plugins-kolab-94339e0e4bebf93fac56aec41232439f2fbb5841.tar.gz
Fix LDAP searches in kolab_auth_ldap::search() when fieldmap does not
contain requested attribute mapping (Bug #2302)
Diffstat (limited to 'plugins/kolab_auth')
-rw-r--r--plugins/kolab_auth/kolab_auth_ldap.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/plugins/kolab_auth/kolab_auth_ldap.php b/plugins/kolab_auth/kolab_auth_ldap.php
index b9b3e4a..2f2ca14 100644
--- a/plugins/kolab_auth/kolab_auth_ldap.php
+++ b/plugins/kolab_auth/kolab_auth_ldap.php
@@ -207,7 +207,7 @@ class kolab_auth_ldap extends rcube_ldap_generic
/**
* Search records (simplified version of rcube_ldap::search)
*
- * @param mixed $fields The field name of array of field names to search in
+ * @param mixed $fields The field name or array of field names to search in
* @param mixed $value Search value (or array of values when $fields is array)
* @param int $mode Matching mode:
* 0 - partial (*abc*),
@@ -221,6 +221,10 @@ class kolab_auth_ldap extends rcube_ldap_generic
*/
function search($fields, $value, $mode=1, $required = array(), $limit = 0)
{
+ if (empty($fields)) {
+ return array();
+ }
+
$mode = intval($mode);
// use AND operator for advanced searches
@@ -236,8 +240,13 @@ class kolab_auth_ldap extends rcube_ldap_generic
}
foreach ((array)$fields as $idx => $field) {
- $val = is_array($value) ? $value[$idx] : $value;
- if ($attrs = (array) $this->fieldmap[$field]) {
+ $val = is_array($value) ? $value[$idx] : $value;
+ $attrs = (array) $this->fieldmap[$field];
+
+ if (empty($attrs)) {
+ $filter .= "($field=$wp" . rcube_ldap_generic::quote_string($val) . "$ws)";
+ }
+ else {
if (count($attrs) > 1)
$filter .= '(|';
foreach ($attrs as $f)
@@ -254,7 +263,13 @@ class kolab_auth_ldap extends rcube_ldap_generic
foreach ((array)$required as $field) {
if (in_array($field, (array)$fields)) // required field is already in search filter
continue;
- if ($attrs = (array) $this->fieldmap[$field]) {
+
+ $attrs = (array) $this->fieldmap[$field];
+
+ if (empty($attrs)) {
+ $req_filter .= "($field=*)";
+ }
+ else {
if (count($attrs) > 1)
$req_filter .= '(|';
foreach ($attrs as $f)