我将在公司门户网站中实施LDAP身份验证。登录后,我需要检索用户在Active Directory中“Office”字段(常规选项卡下)中的值。任何帮助将不胜感激。
以下是我的LDAP身份验证代码供参考:
public function ldap_authentication($username, $password) {
$connection = ldap_connect($this->HOST, $this->PORT) or die("Can't establish LDAP connection");
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($connection) {
$bind = ldap_bind($connection, $username.$this->DOMAIN, $password) or die("Can't bind to LDAP");
if ($bind) {
$authenticated = true;
}
else {
$authenticated = false;
}
}
else {
$authenticated = false;
}
ldap_unbind($connection);
return $authenticated;
}