douzhuan1169 2016-08-15 21:23
浏览 17

ldap在绑定期间获取名称

I think this should have be easy but I’ve been at this for a few hours now. I’m trying to get information from an LDAP server while binding to it. The bind is fine but it times out after 30 seconds saying partial results. If I comment out the search part, the bind is instant (provided the username, password is right) so I know that works. I’d like to get all the information LDAP has on that username, but I’d settle for just the name.

    $ldapuser = 'mypassword';
    $ldappass = 'myusername';

    $ldapconn = ldap_connect("ldap://ds.cisco.com:389")
    or die("Could not connect to the ldap server");

    if($bind = @ldap_bind($ldapconn, $ldapuser."@cisco.com", $ldappass)) {
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
$filter = "(uid=" . $ldapuser."@cisco.com" . ")";
$ldap_dn = "DC=cisco,DC=com";
$attr = array("sn","cn");
$result = ldap_search($ldapconn, $ldap_dn, $filter, $attr) or exit("Unable to search LDAP server");
$entries = ldap_first_entry($ldapconn, $result);
ldap_unbind($ldapconn);


echo '<pre>';
print_r($entries);  
echo '</pre>';

}
  • 写回答

1条回答 默认 最新

  • douhu2890 2016-08-16 15:59
    关注

    Try changing:

    $attr = array("sn","cn");
    

    to:

    $attr = array( );
    

    -jim

    评论

报告相同问题?