I have a problem while trying to connect from an Ubuntu server with PHP5 to a LDAP server using URL('ldap://hostname/').
The code works fine when I'm not using the URL format ($server = 'hostname'
).
The code:
$server = 'ldap://hostname/';
$ldapconn = ldap_connect($server, 3268) or die("Could not connect to LDAP server.");
if ($ldapconn) {
$ldapbind = @ldap_bind($ldapconn, 'username', 'password');
$error_ldap_code = ldap_errno($ldapconn) ;
if($error_ldap_code==0) {
echo 'Connected!!!';
}
}
Edit:
I needed ldaps
, but I saw that with ldap
I have the same problem. While the problem related to ldap was solved by adding the port in the URL, I still had the ldaps issue. Anyway, I managed to bypass it by using ldap_start_tls ( resource $link )
after connecting using only the hostname (without URL format).