Allow LDAP queries without objectClass filter

This commit is contained in:
Thomas Gelf 2014-03-21 10:31:12 +00:00
parent f24e5eaa8a
commit fea7e8993b

View File

@ -313,8 +313,8 @@ class Query
protected function render() protected function render()
{ {
$parts = array(); $parts = array();
if ($this->filters['objectClass'] === null) { if (! isset($this->filters['objectClass']) || $this->filters['objectClass'] === null) {
throw new Exception('Object class is mandatory'); // throw new Exception('Object class is mandatory');
} }
foreach ($this->filters as $key => $value) { foreach ($this->filters as $key => $value) {
$parts[] = sprintf( $parts[] = sprintf(
@ -323,7 +323,11 @@ class Query
LdapUtils::quoteForSearch($value, true) LdapUtils::quoteForSearch($value, true)
); );
} }
return '(&(' . implode(')(', $parts) . '))'; if (count($parts) > 1) {
return '(&(' . implode(')(', $parts) . '))';
} else {
return '(' . $parts[0] . ')';
}
} }
/** /**