0
我将在公司门户网站中实施LDAP身份验证。登录后,我需要在Active Directory中的“Office”字段(常规选项卡下)中检索用户具有的值。任何帮助将不胜感激。PHP 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;
}
你可能想尝试实现http://adldap.sourceforge.net/,这简化了很多与AD的交互。 –