From fea7e8993b776e6d03eb06dce31635577029ed41 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 21 Mar 2014 10:31:12 +0000 Subject: [PATCH] Allow LDAP queries without objectClass filter --- library/Icinga/Protocol/Ldap/Query.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php index eeb9cf8ef..13193885e 100644 --- a/library/Icinga/Protocol/Ldap/Query.php +++ b/library/Icinga/Protocol/Ldap/Query.php @@ -313,8 +313,8 @@ class Query protected function render() { $parts = array(); - if ($this->filters['objectClass'] === null) { - throw new Exception('Object class is mandatory'); + if (! isset($this->filters['objectClass']) || $this->filters['objectClass'] === null) { + // throw new Exception('Object class is mandatory'); } foreach ($this->filters as $key => $value) { $parts[] = sprintf( @@ -323,7 +323,11 @@ class Query LdapUtils::quoteForSearch($value, true) ); } - return '(&(' . implode(')(', $parts) . '))'; + if (count($parts) > 1) { + return '(&(' . implode(')(', $parts) . '))'; + } else { + return '(' . $parts[0] . ')'; + } } /**