I have this simple php file:
$ldap="localhost";
$port=636;
$usr="CN=admin";
$pwd="pwd123";
$ds=ldap_connect("$ldap", $port);
$ldapbind=false;
// for debugging
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 9);
if(ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
if(ldap_set_option($ds, LDAP_OPT_X_TLS_REQUIRE_CERT, 0))
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 "BIND ERROR!\n";
else
echo "BIND OK!\n";
Where I try to connect and bind an ldap server on localhost. (command: php testcon.php). I've added the TLS_REQCERT never line to /etc/ldap.conf as well.
But I got BIND ERROR! result. Furthermore I got warning msg as well:
PHP Warning: ldap_start_tls(): Unable to start TLS: Can't contact LDAP server in /root/testfolder/testcon.php on line 16
If I comment out the 16. line I got no warning, but BIND ERROR! stays.
Furher Infos:
- PHP version: PHP 7.2.5
- server: openSUSE Leap 15.0
- ldap: active directory 2.4.46-lp150.7.1
- The required php libs are isntalled
I try with basedn and without base dn (same result).
ldap_start_tls()) it encrypts the connection.