简体   繁体   中英

ldap get name during bind

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>';

}

Try changing:

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

to:

$attr = array( );

-jim

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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