Created
January 17, 2017 23:03
-
-
Save travstoll/42dac30027c9e5ee45617b0db7062f3a to your computer and use it in GitHub Desktop.
Simple LDAP Authentication Shell
This file contains 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
<? | |
$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