diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index ca0cbab39258817c329f1c73191cc69f7b0383ce..85cb36f31f2447a5e7d48fbd5371f3e89f9673e2 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -159,50 +159,41 @@ class Ldap
 			dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
 		}
 
-		// Loop on each ldap server
-		foreach ($this->server as $key => $host)
+		if (! function_exists("ldap_connect"))
 		{
-			if ($connected) break;
-			if (empty($host)) continue;
-
-			if (preg_match('/^ldap/',$host))
-			{
-				$this->connection = ldap_connect($host);
-			}
-			else
-			{
-				$this->connection = ldap_connect($host,$this->serverPort);
-			}
+			$this->error='LDAPFunctionsNotAvailableOnPHP';
+			$return=-1;
+			dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
+		}
 
-			if (is_resource($this->connection))
+		if (empty($this->error))
+		{
+			// Loop on each ldap server
+			foreach ($this->server as $key => $host)
 			{
-				// Execute the ldap_set_option here (after connect and before bind)
-				$this->setVersion();
-				ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true.
-
-
-				if ($this->serverType == "activedirectory")
+				if ($connected) break;
+				if (empty($host)) continue;
+	
+				if (preg_match('/^ldap/',$host))
 				{
-					$result=$this->setReferrals();
-					dol_syslog(get_class($this)."::connect_bind try bindauth for activedirectory on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
-					$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
-					if ($this->result)
-					{
-						$this->bind=$this->result;
-						$connected=2;
-						break;
-					}
-					else
-					{
-						$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
-					}
+					$this->connection = ldap_connect($host);
 				}
 				else
 				{
-					// Try in auth mode
-					if ($this->searchUser && $this->searchPassword)
+					$this->connection = ldap_connect($host,$this->serverPort);
+				}
+	
+				if (is_resource($this->connection))
+				{
+					// Execute the ldap_set_option here (after connect and before bind)
+					$this->setVersion();
+					ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true.
+	
+	
+					if ($this->serverType == "activedirectory")
 					{
-						dol_syslog(get_class($this)."::connect_bind try bindauth on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
+						$result=$this->setReferrals();
+						dol_syslog(get_class($this)."::connect_bind try bindauth for activedirectory on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
 						$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
 						if ($this->result)
 						{
@@ -215,26 +206,45 @@ class Ldap
 							$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
 						}
 					}
-					// Try in anonymous
-					if (! $this->bind)
+					else
 					{
-						dol_syslog(get_class($this)."::connect_bind try bind on ".$host,LOG_DEBUG);
-						$result=$this->bind();
-						if ($result)
+						// Try in auth mode
+						if ($this->searchUser && $this->searchPassword)
 						{
-							$this->bind=$this->result;
-							$connected=1;
-							break;
+							dol_syslog(get_class($this)."::connect_bind try bindauth on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
+							$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
+							if ($this->result)
+							{
+								$this->bind=$this->result;
+								$connected=2;
+								break;
+							}
+							else
+							{
+								$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
+							}
 						}
-						else
+						// Try in anonymous
+						if (! $this->bind)
 						{
-							$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
+							dol_syslog(get_class($this)."::connect_bind try bind on ".$host,LOG_DEBUG);
+							$result=$this->bind();
+							if ($result)
+							{
+								$this->bind=$this->result;
+								$connected=1;
+								break;
+							}
+							else
+							{
+								$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
+							}
 						}
 					}
 				}
+	
+				if (! $connected) $this->close();
 			}
-
-			if (! $connected) $this->close();
 		}
 
 		if ($connected)
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index dd1615d742759878f21155b407e3c9ab4d7f0c6b..3a7485350cebebd965924d0c37f1fd98c3916624 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -732,17 +732,24 @@ function activateModule($value,$withdeps=1)
         if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends))
         {
             // Activation des modules dont le module depend
+            $TError=array();
             $num = count($objMod->depends);
             for ($i = 0; $i < $num; $i++)
             {
+            	$activate = false;
             	foreach ($modulesdir as $dir)
             	{
             		if (file_exists($dir.$objMod->depends[$i].".class.php"))
             		{
             			activateModule($objMod->depends[$i]);
+						$activate = true;
             		}
             	}
+				
+				if (!$activate) $TError[] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]);
             }
+            
+            setEventMessages('', $TError, 'errors');
         }
 
         if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith))
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 5966578021a6f773f6fa81fa450cb87150728b3f..925c822cfcf2084ae6b2713348b0ee907ca678e4 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1563,3 +1563,4 @@ TypePaymentDesc=0:Customer payment type, 1:Supplier payment type, 2:Both custome
 IncludePath=Include path (defined into variable %s)
 NoModueToManageStockDecrease=No module able to manage automatic stock decrease has been activated. Stock decrease will be done on manual input only.
 NoModueToManageStockIncrease=No module able to manage automatic stock increase has been activated. Stock increase will be done on manual input only.
+activateModuleDependNotSatisfied=Module "%s" depends on module "%s" that is missing, so module "%1$s" may not work correclty. Please install module "%2$s" or disable module "%1$s" if you want to be safe from any surprise
\ No newline at end of file