dqwh1209
2019-01-25 14:27
浏览 138
已采纳

ldap_search返回空数组

I give up :(

Using ldapsearch in ubuntu:

ldapsearch -x -LLL -h xx.xxxx.xx:3268 -D login -w password -b "DC=uni-xx,DC=xx" -v -s sub "userprincipalname=xx8870@student.xxx.xx"

returns correct informations for this user.

Moving to php on the same server:

if (($connect = ldap_connect($ldap_server, $obj->port))) {

ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, $obj->LDAP_OPT_PROTOCOL_VERSION);          

$dn = $obj->contexts; //"DC=uni-xx,DC=xx"
$bu = $obj->bind_user; //login
$bp = $obj->bind_pw; //password
$bind = ldap_bind($connect, $bu, $bp); 

if($bind){

    $is_tu_user = ldap_search($connect, $dn, "(userprincipalname=*xx8870*)", array("cn", "mail"));
    echo ldap_error($connect);
    $info = ldap_get_entries($connect, $is_tu_user);
    print_r(" sss " . json_encode($info));die();
    }
}

returns array with zero elements:

{"count":0}

PHP is version 7.2. LDAP extension is up and running.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题