如果我的查询过滤器正确,我正在使用PHP Skript进行测试。 但我只能使用filter =“(objectclass = *)”进行查询,而ii则不知道原因。
你明白为什么吗?
PHP脚本如下所示:
<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection
$password = 'myPassword';
$bindDn = 'ldapsync';
$searchDn = 'DC=test,DC=local';
$filter = '(objectClass=*)';
$host = '10.10.10.10';
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect($host); // must be a valid LDAP server!
echo "connect result is " . $ds . "<br />";
if ($ds) {
echo "Binding ...";
@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$r=ldap_bind($ds, $bindDn, $password);
echo "Bind result is " . $r . "<br />";
echo "Searching for " . $filter . " ..."; // this is a test campusid
// Search surname entry
$sr=ldap_search($ds, $searchDn, $filter);
echo "Search result is " . $sr . "<br />";
echo "Number of entires returned is " . ldap_count_entries($ds, $sr) . "<br />";
echo "Getting entries ...<p>";
$info = ldap_get_entries($ds, $sr);
echo "Data for " . $info["count"] . " items returned:<p>";
for ($i=0; $i<$info["count"]; $i++) {
echo "dn is: " . $info[$i]["dn"] . "<br />";
echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />";
//echo "first type is: " . $info[$i]["type"][0] . "<br /><hr />";
}
echo "Closing connection";
ldap_close($ds);
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
?>