Hi
I try to connect to an ADSI tree. When try to connect ananymously : it's works, but I can get many result.
When I try to bing with my login I get an error message.
I use the ldp.exe tools. When I bind with my login : It's works.
Any Ideas ?
Thanks in advance.
dev plateform : w2k + apache 1.3.17 + PHP4pl1
code :
<?
$basedn="dc=alladin,dc=net";
$filter="cn=*S*";
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("administration","3268"); // must be a valid LDAP server!
echo "connect result is ".$ds."<p>";
if ($ds) {
echo "Binding ...";
$r=ldap_bind($ds); // this is an "anonymous" bind, typically
// read-only access
echo "Bind result is ".$r."<p>";
echo "Searching for (sn=S*) ...";
// Search surname entry
$sr=ldap_search($ds,$basedn,$filter);
if (!$sr) {
printf("LDAP-Errno: %s<br>\n", ldap_errno($ds));
printf("LDAP-Error: %s<br>\n", ldap_error($ds));
die("Argh!<br>\n");
}
echo "Search result is ".$sr."<p>";
echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>";
echo ldap_error($ds);
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 email entry is: ". $info[$i]["mail"][0] ."<p>";
}
echo "Closing connection";
ldap_close($ds);
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
?>
I try to connect to an ADSI tree. When try to connect ananymously : it's works, but I can get many result.
When I try to bing with my login I get an error message.
I use the ldp.exe tools. When I bind with my login : It's works.
Any Ideas ?
Thanks in advance.
dev plateform : w2k + apache 1.3.17 + PHP4pl1
code :
<?
$basedn="dc=alladin,dc=net";
$filter="cn=*S*";
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("administration","3268"); // must be a valid LDAP server!
echo "connect result is ".$ds."<p>";
if ($ds) {
echo "Binding ...";
$r=ldap_bind($ds); // this is an "anonymous" bind, typically
// read-only access
echo "Bind result is ".$r."<p>";
echo "Searching for (sn=S*) ...";
// Search surname entry
$sr=ldap_search($ds,$basedn,$filter);
if (!$sr) {
printf("LDAP-Errno: %s<br>\n", ldap_errno($ds));
printf("LDAP-Error: %s<br>\n", ldap_error($ds));
die("Argh!<br>\n");
}
echo "Search result is ".$sr."<p>";
echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>";
echo ldap_error($ds);
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 email entry is: ". $info[$i]["mail"][0] ."<p>";
}
echo "Closing connection";
ldap_close($ds);
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
?>