Created
September 2, 2016 13:58
-
-
Save ClaudioVarandas/1225fa991d00b0a127e2ee4bb2b67ce2 to your computer and use it in GitHub Desktop.
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 | |
$ldaprdn = "uid=test,ou=test,dc=test,dc=test,dc=pt"; | |
$ldappass = "xxx"; | |
$basedn = "dc=test,dc=pt"; | |
// if no ldap.conf or ldaprc configured, need to put certificate in environment | |
putenv('LDAPTLS_CACERT=./ca.pem'); | |
//Enable debug | |
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); | |
// connect to ldap server | |
if (!$ldapconn = ldap_connect("ldaps://x.x.x.x","636")) { | |
die ("Could not connect to LDAP server"); | |
} | |
// set protocol version | |
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); | |
if (false === @ldap_bind($ldapconn)) { | |
throw new Exception("Error: " . ldap_errno($ldapconn) . " Message: " . ldap_error($ldapconn)); | |
} else { | |
echo(".........................................connected !!!". PHP_EOL); | |
} | |
ldap_close($ldapconn); | |
exit("End"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment