Hey Guys an Girls
I am trying to write a PHP page to connect to one of my DC's to authenticate users. I havnt played with LDAP before and my knowledge of PHP is limited, so I'm a bit lost in the dark at the moment...
I have a Ubuntu server for the site, with the latest PHP, and I have told it to install LDAP, I wasnt sure if I had to do anything after installing it....
I have patched together a PHP script which connects to my server and binds successfully, apparantly. I then want to search for a user called ben and display his details, just to check everything is working.
It tells me I have connected using this;
When I add the following code the page stops working and just goes white...PHP Code:// LDAP variables
$ldaphost = "ldap://myserver/"; // your ldap servers
$ldapport = myport; // your ldap server's port number
// Connecting to LDAP
$ldapconn = ldap_connect($ldaphost, $ldapport)
or die("Could not connect to $ldaphost");
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
echo "LDAP bind successful...$ldaprdn";
} else {
echo "LDAP bind failed...";
}
}
What have I forgotten to configure? Is there another setting on the DC I need to enable??? Im Pulling my hair out and dont want to leave it unfixed on a Friday!PHP Code:$ds=dc2
$person = "ben"
$dn = "dc=mydomain, dc=local";
$filter="(|(sn=$person*)(givenname=$person*))";
$justthese = array("ou", "sn", "givenname", "mail");
$sr=ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
echo $info["count"]." entries returned\n";



LinkBack URL
About LinkBacks
Reply With Quote

