-
-
Save joemiller/3d8bce6d50dae985e807 to your computer and use it in GitHub Desktop.
test php ldap with starttls
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 | |
| // basic sequence with LDAP is connect, bind, search, interpret search | |
| // result, close connection | |
| echo "<h3>LDAP query test</h3>"; | |
| echo "Connecting ..."; | |
| if (! $ds=ldap_connect("<INSERT_LDAPS_SERVER_THAT_SUPPORTS_STARTTLS_HERE>")) { | |
| echo "Failed to connect to LDAP server\n"; | |
| exit; | |
| } | |
| echo "connect result is " . $ds . "\n"; | |
| ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); | |
| ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); | |
| ldap_set_option($ds, LDAP_OPT_REFERRALS, 0); | |
| if (! ldap_start_tls($ds)) { | |
| echo "Could not start TLS." . ldap_errno($ds) . " " . ldap_error($ds) . "\n"; | |
| exit; | |
| } else { | |
| echo "start tls success\n"; | |
| } | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the LDAP_OPT_DEBUG_LEVEL set to 7, you will get a ton of useful output. Here is an example of how this was used to track down the error to an empty
/etc/openldap/certsdir:GOOD:
BAD: