diff --git a/inc/auth/ldap.class.php b/inc/auth/ldap.class.php index ac067c88869491bc72a3b386964d509bee729e86..f59800476ca6811e4474abe77968c075926d6690 100644 --- a/inc/auth/ldap.class.php +++ b/inc/auth/ldap.class.php @@ -11,6 +11,7 @@ class auth_ldap extends auth_basic { var $cnf = null; var $con = null; + var $bound = false; /** * Constructor @@ -78,6 +79,7 @@ class auth_ldap extends auth_basic { } return false; } + $this->bound = true; return true; }else{ // See if we can find the user @@ -96,6 +98,7 @@ class auth_ldap extends auth_basic { } return false; } + $this->bound = true; return true; } @@ -128,6 +131,18 @@ class auth_ldap extends auth_basic { global $conf; if(!$this->_openLDAP()) return false; + if(!$this->bound){ + if($this->cnf['binddn'] && $this->cnf['bindpw']){ + // use superuser credentials + if(!@ldap_bind($this->con,$this->cnf['binddn'],$this->cnf['bindpw'])){ + if($this->cnf['debug']) + msg('LDAP bind as superuser: '.htmlspecialchars(ldap_error($this->con)),0); + return false; + } + } + $this->bound = true; + } + $info['user'] = $user; $info['server'] = $this->cnf['server'];