Fix: pas de connexion pour active directory

This commit is contained in:
Regis Houssin 2007-05-29 15:04:59 +00:00
parent 2bd8e9bd67
commit cad99d7b56

View File

@ -190,7 +190,7 @@ class Ldap
*/ */
function connect_bind() function connect_bind()
{ {
global $conf,$langs; global $langs;
$connected=0; $connected=0;
$this->bind=0; $this->bind=0;
@ -215,8 +215,8 @@ class Ldap
if ($this->serverType == "activedirectory") if ($this->serverType == "activedirectory")
{ {
$result=$this->setReferrals(); $result=$this->setReferrals();
dolibarr_syslog("Ldap::connect_bind try bindauth for activedirectory on ".$host." user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG); dolibarr_syslog("Ldap::connect_bind try bindauth for activedirectory on ".$host." user=".$this->searchUser,LOG_DEBUG);
$this->result=$this->bindauth($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS); $this->result=$this->bindauth($this->searchUser,$this->searchPassword);
if ($this->result) if ($this->result)
{ {
$this->bind=$this->result; $this->bind=$this->result;
@ -231,10 +231,10 @@ class Ldap
else else
{ {
// Try in auth mode // Try in auth mode
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS) if ($this->searchUser && $this->searchPassword)
{ {
dolibarr_syslog("Ldap::connect_bind try bindauth on ".$host." user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG); dolibarr_syslog("Ldap::connect_bind try bindauth on ".$host." user=".$this->searchUser,LOG_DEBUG);
$this->result=$this->bindauth($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS); $this->result=$this->bindauth($this->searchUser,$this->searchPassword);
if ($this->result) if ($this->result)
{ {
$this->bind=$this->result; $this->bind=$this->result;
@ -364,7 +364,6 @@ class Ldap
* \return version * \return version
*/ */
function setVersion() { function setVersion() {
global $conf;
// LDAP_OPT_PROTOCOL_VERSION est une constante qui vaut 17 // LDAP_OPT_PROTOCOL_VERSION est une constante qui vaut 17
$ldapsetversion = ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion); $ldapsetversion = ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion);
return $ldapsetversion; return $ldapsetversion;
@ -375,7 +374,6 @@ class Ldap
* \return referrals * \return referrals
*/ */
function setReferrals() { function setReferrals() {
global $conf;
// LDAP_OPT_REFERRALS est une constante qui vaut ? // LDAP_OPT_REFERRALS est une constante qui vaut ?
$ldapreferrals = ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); $ldapreferrals = ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
return $ldapreferrals; return $ldapreferrals;