Skip to content

Instantly share code, notes, and snippets.

@samueljon
Created March 14, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueljon/3ac8b4f6a45352b2017b3b481a22068f to your computer and use it in GitHub Desktop.
Save samueljon/3ac8b4f6a45352b2017b3b481a22068f to your computer and use it in GitHub Desktop.
For debugging ldap connectivity issues in php
<?php
$ldap="host.domain.tld";
$usr="user@domain.tld";
$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