Skip to content

Instantly share code, notes, and snippets.

@travstoll
Created January 17, 2017 23:03
Show Gist options
  • Save travstoll/42dac30027c9e5ee45617b0db7062f3a to your computer and use it in GitHub Desktop.
Save travstoll/42dac30027c9e5ee45617b0db7062f3a to your computer and use it in GitHub Desktop.
Simple LDAP Authentication Shell
<?
$user = '<AD_User>'; // get from post
$ldappass = '<AD_Password>'; // associated password
// using ldap bind
$ldaprdn = $user . '@<domain>.local'; // ldap rdn or dn
$ldap_server = 'ldap://<domaindc>'; //domain controller
// connect to ldap server
$ldapconn = ldap_connect($ldap_server, 389)
or die("Could not connect to LDAP server.");
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 "LDAP Connection to " . $ldap_server . "failed";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment