I am trying to implement a LDAP connection through PHP for an internal web page. I use Uniform Server for my PHP. http://www.uniformserver.com/ . As a test I am trying to connect to the test server here. http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
But I don't understand it seem like it doesn't even go in the if/else statements.
Here's my code :
<?php
$ldapServer = 'ldap.forumsys.com';
$ldapPort = 389;
if(isset($_POST['username']) && isset($_POST['password'])){
echo "Hello both parameters are set";
$username = $_POST['username'];
$password = $_POST['password'];
echo "<br>" . $username;
echo "<br>" . $password;
$ds = ldap_connect($ldapServer, $ldapPort);
if (ldap_bind($ds, $_POST['username'], $_POST['password'])) {
// Successful auth
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
// log them in!
echo 'you are logged in ' . $_SESSION['username'] ;
//redirect after logged in2
} else {
// error message
echo 'auth failed';
}
}
else
{
?>
<form action="login.php" method="POST">
<label for="username">Username: </label><input id="username" type="text" name="username" required="true" />
<label for="password">Password: </label><input id="password" type="password" name="password" required="true" /> <input type="submit" name="submit" value="Submit" />
</form>
<?php
} ?>
My first echos are shown (password and username) but nothing after that is shown. Anyone sees why? I don' have any errors but here's my response.
Hello both parameters are set
username
password
Thanks
E_WARNING
level message. Have you checked your PHP logs? Do you have logging enabled? – Robert Rossmann