简体   繁体   English

ldap在绑定期间获取名称

[英]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. 我试图在绑定到LDAP服务器时从其获取信息。 The bind is fine but it times out after 30 seconds saying partial results. 绑定很好,但30秒后超时,表明部分结果。 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. 我想获取LDAP在该用户名上拥有的所有信息,但是我只想使用该名称。

    $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 -吉姆

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

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