請問大大
我要透過PHP連結AD去查詢USER資料,可是怎麼都一直撈不到資料,可否協助查看一下,感謝
<?php
$domain = '1234.corp';
$ldaprdn = 'ABC';
$ldappass = '123';
$ldapconn = ldap_connect($domain) or die("無法連接至 $domain");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
if ($ldapconn) { // binding to ldap server
// $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
$filter = "(samaccountname='user')";
$_dn = str_replace('OU=xxxxx','DC=xxxxx','DC=corp'. $domain);
$result = ldap_search($ldapconn, $_dn, $filter);
$info = ldap_get_entries($ldapconn, $result);
print_r($info);
} else {
echo "認證失敗...";
}
}
?>
輪出結果為下:Array ( [count] => 0 ) ?>