Page 1 of 1

php ldap_bind on osx server 10.2.6

Posted: Thu May 29, 2003 6:10 am
by skumhest
Hi.
i just tried to a authenticated bind on my "Open Directory" (open ldap netinfo frontend) through php with som code from zend.
and it don't seem to work :(


this is the output:
-----------------------------
LDAP query test
Connecting ...connect result is Resource id #2

Binding ...
Warning: ldap_bind(): Unable to bind to server: Invalid credentials in /Library/WebServer/Documents/php/test.php on line 12
Bind result is

Searching for (sn=S*) ...Search result is Resource id #3

Number of entires returned is 0

Getting entries ...

Data for 0 items returned:

Closing connection
--------------------------------------------------

this is the code:
-------------------------------
<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection

echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("localhost"); // must be a valid LDAP server!
echo "connect result is ".$ds."<p>";

if ($ds) {
echo "Binding ...";
$r=ldap_bind($ds, "uid=test,cn=Users,dc=local", "test");
echo "Bind result is ".$r."<p>";

echo "Searching for (sn=S*) ...";
// Search surname entry
$sr=ldap_search($ds,"dc=local", "sn=S*");
echo "Search result is ".$sr."<p>";

echo "Number of entires returned is ".ldap_count_entries($ds,$sr)."<p>";

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>";
}
?>
------------------------------------------------------

it seems to indecate thet my password is not correct ( which it is! and so is the dc=local thing).

does anyone have an idea?
does the ldap_bind expect that the server will entrypt the password before it compares it to the entry in the ldap database?

Thanks in advance
Tobias