2011-11-04 30 views
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; 
} 
+0

你可能想尝试实现http://adldap.sourceforge.net/,这简化了很多与AD的交互。 –

回答

0

一旦绑定成功,你需要做的ldap_search,其次是ldap_get_entries。您应该在上述链接中找到大量示例。

+0

感谢您的指导。一旦找到解决方法,我会尽快与您联系。 – Brett

相关问题