简体   繁体   English

PHP LDAP从Active Directory获取“ Office”字段

[英]PHP LDAP get “Office” field from Active Directory

I will be implementing LDAP authentication into a company web portal. 我将在公司的Web门户中实施LDAP身份验证。 Once they login, I need to retrieve the value that user has in the "Office" field (under the general tab) in Active Directory. 他们登录后,我需要检索用户在Active Directory中“ Office”字段(在“常规”选项卡下)中拥有的值。 Any help would be greatly appreciated. 任何帮助将不胜感激。

Here is my LDAP authentication code for reference: 这是我的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;
}

Once your bind is successful, you need to do an ldap_search , followed by ldap_get_entries . 绑定成功后,您需要执行ldap_search ,然后执行ldap_get_entries You should find plenty of examples at the aforementioned links. 您可以在上述链接中找到大量示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM