wiggum123 Posted March 4, 2011 Posted March 4, 2011 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; // 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..."; } } When I add the following code the page stops working and just goes white... $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"; 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!
danbuntu Posted March 4, 2011 Posted March 4, 2011 turn php error reporting on and use a proper browser like firefox and that will show you the error rather than a white screen.
ZeroHour Posted March 4, 2011 Posted March 4, 2011 Also if you use IIS + php you can use native integrate auth.
CyberNerd Posted March 5, 2011 Posted March 5, 2011 apache has a native ldap authentication module: mod_auth_ldap - Apache HTTP Server
PaulBM Posted March 5, 2011 Posted March 5, 2011 The first two lines of that second block of code look wrong to me. $ds=dc2 Should that be $ds="dc2"; ? I expect that line to be giving you a syntax error. And the second line is missing it's semi-colon, which will also generate a syntax error. Add error_reporting['E_ALL']; to the top of the code and run the it again. Take the reporting line out when you're happy it's working.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now