From 66018b89b26313f168669bb1dd5c8b701964782a Mon Sep 17 00:00:00 2001
From: Arthur Schiwon <blizzz@owncloud.com>
Date: Mon, 16 Apr 2012 18:03:02 +0200
Subject: [PATCH] LDAP: don't forget to unbind

---
 apps/user_ldap/lib_ldap.php | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php
index ab815171b8..eea4a82011 100644
--- a/apps/user_ldap/lib_ldap.php
+++ b/apps/user_ldap/lib_ldap.php
@@ -23,6 +23,13 @@
 
 define('LDAP_GROUP_MEMBER_ASSOC_ATTR','memberUid');
 
+//needed to unbind, because we use OC_LDAP only statically
+class OC_LDAP_DESTRUCTOR {
+	public function __destruct() {
+		OC_LDAP::destruct();
+	}
+}
+
 class OC_LDAP {
 	static protected $ldapConnectionRes = false;
 	static protected $configured = false;
@@ -43,6 +50,10 @@ class OC_LDAP {
 		self::establishConnection();
 	}
 
+	static public function destruct() {
+		@ldap_unbind(self::$ldapConnectionRes);
+	}
+
 	static public function conf($key) {
 		$availableProperties = array(
 			'ldapUserDisplayName',
-- 
GitLab