2
modificate auth_ldap.php
function authenticate($uname, $pwd = null) {
$authenticated = false;
if (!extension_loaded('ldap')) {
$this->setErrors(0, _AUTH_LDAP_EXTENSION_NOT_LOAD);
return $authenticated;
}
$this->_ds = ldap_connect($this->ldap_server, $this->ldap_port);
if ($this->_ds) {
ldap_set_option($this->_ds, LDAP_OPT_PROTOCOL_VERSION, $this->ldap_version);
ldap_set_option($this->_ds, LDAP_OPT_REFERRALS, 0);
// If the uid is not in the DN we proceed to a search
// The uid is not always in the dn
$userDN = $this->getUserDN($uname);
if (!$userDN) return false;
// We bind as user to test the credentials
$authenticated = ldap_bind($this->_ds, $userDN, stripslashes($pwd));
if ($authenticated) {
// We load the XOOPS User database
return $this->loadXoopsUser($userDN, $uname, $pwd);
} else $this->setErrors(ldap_errno($this->_ds), ldap_err2str(ldap_errno($this->_ds)) . '(' . $userDN . ')');
}
else {
$this->setErrors(0, _AUTH_LDAP_SERVER_NOT_FOUND);
}
@ldap_close($this->_ds);
return $authenticated;
}