Hi,
Can somebody please help me with this code?
I want to connect to an ldap server (Exchange server) and read some user names, emails, etc.
I connect sucessfully but I can't read any entries.
this is the error i get.:
Warning: LDAP: Unable to perform the search: Operations error in /var/www/intradev/ldap2.php on line 17
And here are my code:
<?php
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("myldapserver.myserver.com");
echo "connect result is ".$ds."<p>";
if ($ds) {
echo "Binding ...";
$r=ldap_bind($ds);
echo "Bind result is ".$r."<p>";
$query = "cn=Christa*";
echo "Searching for Common Name: ".$query;
// Search surname entry
$sr=ldap_search($ds,"c=US", $query); //line 17
echo "Search result is ".$sr."<p>";
if ($sr > 0) {
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>";
}
?>
Can someone please help???