Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP code for adding Ldap login
#2
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";
}
?>
  


Messages In This Thread
PHP code for adding Ldap login - by andrew - 10-29-2023, 03:56 PM
PHP code for adding Ldap login - by rpgking - 10-29-2023, 03:56 PM
RE: PHP code for adding Ldap login - by andrew - 10-29-2023, 04:12 PM
RE: PHP code for adding Ldap login - by welly321 - 10-29-2023, 04:13 PM

Forum Jump:


Users browsing this thread:
3 Guest(s)