From 65821863faf1f4c9e0f5f370133c16014f6087c8 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 27 Feb 2015 16:59:50 +0100 Subject: [PATCH] Don't crash on single ldap capability entries refs #8490 --- library/Icinga/Protocol/Ldap/Capability.php | 30 ++++++++------------- library/Icinga/Protocol/Ldap/Connection.php | 1 - 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Capability.php b/library/Icinga/Protocol/Ldap/Capability.php index a1da67ce2..76d1f11a0 100644 --- a/library/Icinga/Protocol/Ldap/Capability.php +++ b/library/Icinga/Protocol/Ldap/Capability.php @@ -101,24 +101,16 @@ class Capability { { $this->attributes = $attributes; - if (isset($attributes->supportedControl)) { - foreach ($attributes->supportedControl as $oid) { - $this->oids[$oid] = true; - } - } - if (isset($attributes->supportedExtension)) { - foreach ($attributes->supportedExtension as $oid) { - $this->oids[$oid] = true; - } - } - if (isset($attributes->supportedFeatures)) { - foreach ($attributes->supportedFeatures as $oid) { - $this->oids[$oid] = true; - } - } - if (isset($attributes->supportedCapabilities)) { - foreach ($attributes->supportedCapabilities as $oid) { - $this->oids[$oid] = true; + $keys = array('supportedControl', 'supportedExtension', 'supportedFeatures', 'supportedCapabilities'); + foreach ($keys as $key) { + if (isset($attributes->$key)) { + if (is_array($attributes->$key)) { + foreach ($attributes->$key as $oid) { + $this->oids[$oid] = true; + } + } else { + $this->oids[$attributes->$key] = true; + } } } } @@ -160,7 +152,7 @@ class Capability { */ public function hasLdapV3() { - if (!isset($this->attributes)) { + if (! isset($this->attributes) || ! isset($this->attributes->supportedLDAPVersion)) { // Default to true, if unknown return true; } diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 39e447486..57b1617a5 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -469,7 +469,6 @@ class Connection protected function prepareNewConnection() { $use_tls = false; - $force_tls = true; $force_tls = false; if ($use_tls) {