我正在尝试通过LDAP
in连接到活动目录php
。但我收到以下警告:
警告:ldap_search():提供的参数不是第 39 行 C:\Program Files (x86)\EasyPHP-12.1\www\GuestRegister\login.php 中的有效 ldap 链接资源
警告:ldap_get_entries() 期望参数 1 是资源,在 C:\Program Files (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";
}
}
?>