Try this and see if it works. I had the same problem until I did a little
reading. I had to use [EMAIL PROTECTED] as username then I didn't get
the credential errors anymore.
hope this helps, its very basic but hopefully it gets you started.
********* Config.php**********************
<?php
//LDAP connection parameters array
$ldapcfg = array();
//Set default LDAP port
//The default is 389, don't change unless you know
//absolutely that its different.
$ldapcfg["port"] = 389;
//Set LDAP servername to connect to
$ldapcfg["server"] = 'server_name';
//Set ldap username for binding to server
$ldapcfg["username"] = "[EMAIL PROTECTED]";
//Set password for username
$ldapcfg["password"] = "password";
//Set base DN to search the whole domain
$ldapcfg["basedn"] ='dc=Domain_name, dc=com';
?>
**************index.php************************
<?php
include('config.php');
// specify the LDAP server to connect to
$conn = ldap_connect($ldapcfg["server"]) or die("Could not connect to
server");
// bind to the LDAP server specified above
$bind = ldap_bind($conn,$ldapcfg["username"],$ldapcfg["password"]);
if(!$bind)
{
echo ldap_error($conn);
exit;
}
//There is a optional fourth parameter, that can be added to
//restrict the attributes and values returned by the server
//to just those required when searching.
$params = array("mail", "cn", "sn");
// list all entries from the base DN
$result = ldap_list($conn, $ldapcfg["basedn"], "cn=*");
if ($result)
{
// Lets get the entries from our results
$info = ldap_get_entries($conn, $result);
echo "<p>".$info["count"]."entries returned</p>";
// and print attribute values
for ($i=0; $i<$info["count"]; $i++)
{
echo "<table>";
echo "<tr>";
echo "<td>".$info[$i]["cn"][0]."</td>";
echo "<td>".$info[$i]["sn"][0]."</td>";
echo "</tr>";
echo "</table>";
}
}
// all done? then close the connection...
ldap_close($conn);
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php