Fix LDAP searches in kolab_auth_ldap::search() when fieldmap does not
contain requested attribute mapping (Bug #2302)
This commit is contained in:
parent
bf028bb53f
commit
94339e0e4b
1 changed files with 19 additions and 4 deletions
|
@ -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
|
||||
|
@ -237,7 +241,12 @@ 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]) {
|
||||
$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)
|
||||
|
|
Loading…
Add table
Reference in a new issue