Created
March 27, 2017 15:55
-
-
Save abstraction21/51dd28777ecf5511246581ef414c255b to your computer and use it in GitHub Desktop.
LDAP Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action='' method='post'> | |
LDAP DN: <input type='text' name='ldaprdn' value='<?php echo $_POST["ldaprdn"]; ?>'><br> | |
LDAP PASS: <input type='text' name='ldappass' value='<?php echo $_POST["ldappass"]; ?>'><br> | |
LDAP HOST: <input type='text' name='ldaphost' value='<?php echo $_POST["ldaphost"]; ?>'><br> | |
<input type='submit' value='begin test'><br> | |
</form> | |
<?php | |
//sleep(4); | |
// using ldap bind | |
$ldaprdn = $_POST["ldaprdn"]; | |
$ldappass = $_POST["ldappass"]; // associated password | |
// make sure your host is the correct one | |
// that you issued your secure certificate to | |
$ldaphost = $_POST["ldaphost"]; | |
echo $ldaprdn,"<br>"; | |
echo $ldaphost,"<br>"; | |
ldap_set_option($ldapconn, LDAP_OPT_DEBUG_LEVEL, 7); | |
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); | |
// Connecting to LDAP | |
$ldapconn = ldap_connect($ldaphost, 3269); | |
// 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..."; | |
} else { | |
echo "LDAP bind failed..."; | |
} | |
} else { | |
echo "<br>",ldap_error($ldapconn); | |
} | |
ldap_close($ldapconn); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment