Created
March 14, 2017 13:21
-
-
Save samueljon/f33fae69cb5eaab799faf84ed934f803 to your computer and use it in GitHub Desktop.
For debugging Ldap connectivity issues in php
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
<?php | |
// Set the ldap server | |
$ldapurl = "host.domain.tld"; | |
$ldapuser = "[email protected]"; | |
$ldappass = 'userpassword'; | |
// Set the debug flag | |
$debug = true; | |
// Set debugging | |
if ($debug) { | |
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); | |
} | |
// connect to ldap server | |
$ldapconn = ldap_connect($ldapurl) or die ("Couldn't connect"); | |
// binding to ldap server | |
echo "Trying to bind with $ldapuser - $ldappass\n"; | |
$ldapbind = @ldap_bind($ldapconn, $ldapuser, $ldappass); | |
if (!$ldapbind) { | |
echo "Unable to bind to server $ldapurl\n"; | |
echo "OpenLdap error message: " . ldap_error($ldapconn) . "\n"; | |
exit; | |
} | |
// Rest of code goes here | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment