Code:
<?php
// LDAP authentication
$ldap_host = "ldap.example.com";
$ldap_dn = "ou=people,dc=example,dc=com";
$ldap_user = "username";
$ldap_pass = "password";
// Connect to LDAP server
$ldapconn = ldap_connect($ldap_host) or die("Could not connect to LDAP server.");
// Set some ldap options for talking to
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
// Bind to the LDAP server
$ldapbind = ldap_bind($ldapconn, $ldap_user, $ldap_pass);
// Verify the binding
if ($ldapbind) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
// Image verification or Recaptcha
$captcha = new ReCaptcha('YOUR_SECRET_KEY');
$resp = $captcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
if ($resp != null && $resp->success) {
echo "Captcha verified";
} else {
echo "Captcha verification failed";
}
?>