21 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
31 include_once
$GLOBALS['xoops']->path('class/auth/auth_ldap.php');
49 parent::XoopsAuthLdap($dao);
62 function authenticate(
$uname, $pwd = null)
64 $authenticated =
false;
65 if (!extension_loaded(
'ldap')) {
67 return $authenticated;
69 $this->_ds = ldap_connect($this->ldap_server, $this->ldap_port);
71 ldap_set_option($this->_ds, LDAP_OPT_PROTOCOL_VERSION, $this->ldap_version);
72 ldap_set_option($this->_ds, LDAP_OPT_REFERRALS, 0);
73 if ($this->ldap_use_TLS) {
74 if (!ldap_start_tls($this->_ds)) {
80 $userUPN = $this->getUPN(
$uname);
85 $authenticated = ldap_bind($this->_ds, $userUPN, $this->cp1252_to_utf8(stripslashes($pwd)));
88 $dn = $this->getUserDN(
$uname);
90 return $this->loadXoopsUser($dn,
$uname, $pwd);
95 $this->setErrors(ldap_errno($this->_ds), ldap_err2str(ldap_errno($this->_ds)) .
'(' . $userUPN .
')');
100 @ldap_close($this->_ds);
101 return $authenticated;
114 $userDN =
$uname .
'@' . $this->ldap_domain_name;