0
我正在嘗試通過LDAP
在php
連接到活動目錄。但我得到以下警告:面臨警告使用PHP錯誤鏈接資源的LDAP
警告:ldap_search():提供的參數是不是在C有效的LDAP鏈路資源:\程序文件(x86)\的EasyPHP-12.1 \ WWW \ GuestRegister \的login.php第39行上
警告:ldap_get_entries()預計參數1是資源,在串C中給出:\程序文件(x86)\的EasyPHP-12.1 \ WWW \ GuestRegister \上線的login.php 41個 條目返回
任何人都可以幫忙嗎? :)
我的代碼如下所示:
<?php
$ds = "10.33.85.172";
$ldaprdn = "CN=HackTeam,CN=Users,DC=cisco,DC=internal";
$ldappass = 'HackMe007';
// connect to ldap server
$ldapconn = ldap_connect("10.33.85.172")
or die("Could not connect to LDAP server.");
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
echo "Connected to LDAP";
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0);
$filter="(|(sn=guest-Juan*)(givenname=Juan*))";
$justthese = array("ou", "sn", "givenname", "mail");
$sr=ldap_search($ds, $ldaprdn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
echo $info["count"]." entries returned\n";
} else {
echo "Connection to LDAP Failed";
}
}
?>