From 9aec4d554bc79669ef48e077aefe37231ed6fed7 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 12 Sep 2015 18:21:37 +0200
Subject: [PATCH] Fix #3215 [User card] [Contact card] [Member card] Error in
 LDAP tab

---
 htdocs/admin/ldap.php            | 2 +-
 htdocs/core/class/ldap.class.php | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index ce4ba172583..53c8777d404 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -263,7 +263,7 @@ if (function_exists("ldap_connect"))
 		$ldap = new Ldap();	// Les parametres sont passes et recuperes via $conf
 
 		$result = $ldap->connect_bind();
-		if ($result)
+		if ($result > 0)
 		{
 			// Test ldap connect and bind
 			print img_picto('','info').' ';
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index 98250ab0db1..400eb934e26 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -156,10 +156,17 @@ class Ldap
 		if (count($this->server) == 0 || empty($this->server[0]))
 		{
 			$this->error='LDAP setup (file conf.php) is not complete';
-			$return=-1;
 			dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
+			return -1;
 		}
 
+		if (! function_exists('ldap_connect'))
+		{
+			$this->error='Your PHP need extension ldap';
+			dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
+		    return -1;
+		}
+		
 		// Loop on each ldap server
 		foreach ($this->server as $key => $host)
 		{
-- 
GitLab