2
0
forked from Wavyzz/dolibarr

Merge remote-tracking branch 'origin/3.7' into 3.8

Conflicts:
	htdocs/core/class/ldap.class.php
	htdocs/langs/en_US/admin.lang
This commit is contained in:
Laurent Destailleur
2016-06-05 00:12:34 +02:00
3 changed files with 64 additions and 53 deletions

View File

@@ -160,57 +160,41 @@ class Ldap
return -1; return -1;
} }
if (! function_exists('ldap_connect')) if (! function_exists("ldap_connect"))
{ {
$this->error='Your PHP need extension ldap'; $this->error='LDAPFunctionsNotAvailableOnPHP';
dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING); dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
return -1; $return=-1;
} }
// Loop on each ldap server if (empty($this->error))
foreach ($this->server as $key => $host)
{ {
if ($connected) break; // Loop on each ldap server
if (empty($host)) continue; foreach ($this->server as $key => $host)
if (preg_match('/^ldap/',$host))
{ {
$this->connection = ldap_connect($host); if ($connected) break;
} if (empty($host)) continue;
else
{ if (preg_match('/^ldap/',$host))
$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")
{ {
$result=$this->setReferrals(); $this->connection = ldap_connect($host);
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);
}
} }
else else
{ {
// Try in auth mode $this->connection = ldap_connect($host,$this->serverPort);
if ($this->searchUser && $this->searchPassword) }
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); $this->result=$this->bindauth($this->searchUser,$this->searchPassword);
if ($this->result) if ($this->result)
{ {
@@ -223,26 +207,45 @@ class Ldap
$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection); $this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
} }
} }
// Try in anonymous else
if (! $this->bind)
{ {
dol_syslog(get_class($this)."::connect_bind try bind on ".$host,LOG_DEBUG); // Try in auth mode
$result=$this->bind(); if ($this->searchUser && $this->searchPassword)
if ($result)
{ {
$this->bind=$this->result; dol_syslog(get_class($this)."::connect_bind try bindauth on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
$connected=1; $this->result=$this->bindauth($this->searchUser,$this->searchPassword);
break; 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) if ($connected)

View File

@@ -746,17 +746,24 @@ function activateModule($value,$withdeps=1)
if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends)) if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends))
{ {
// Activation des modules dont le module depend // Activation des modules dont le module depend
$TError=array();
$num = count($objMod->depends); $num = count($objMod->depends);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
$activate = false;
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
{ {
if (file_exists($dir.$objMod->depends[$i].".class.php")) if (file_exists($dir.$objMod->depends[$i].".class.php"))
{ {
activateModule($objMod->depends[$i]); 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)) if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith))

View File

@@ -1690,3 +1690,4 @@ MailToSendSupplierRequestForQuotation=To send quotation request to supplier
MailToSendSupplierOrder=To send supplier order MailToSendSupplierOrder=To send supplier order
MailToSendSupplierInvoice=To send supplier invoice MailToSendSupplierInvoice=To send supplier invoice
MailToThirdparty=To send email from thirdparty page MailToThirdparty=To send email from thirdparty page
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