Created
March 14, 2017 13:26
-
-
Save samueljon/3ac8b4f6a45352b2017b3b481a22068f 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 | |
$ldap="host.domain.tld"; | |
$usr="[email protected]"; | |
$pwd = 'userpassword'; | |
$debug = true; | |
// Set debugging | |
if ($debug) { | |
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); | |
} | |
$ds=ldap_connect($ldap); | |
$ldapbind=false; | |
if(ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) | |
if(ldap_set_option($ds, LDAP_OPT_REFERRALS, 0)) | |
if(ldap_start_tls($ds)) | |
$ldapbind = @ldap_bind($ds, $usr, $pwd); | |
ldap_close($ds); | |
if(!$ldapbind) | |
echo "ERROR"; | |
else | |
echo "OK"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment