I need to connect my application to an external LDAP system. I've managed to connect my application to a local OpenLDAP. But when I try to connect the external one over SSL I get some troubles.
My code:
public static function ldapConnection($server, $port, $version, $auth_user,
$auth_pass, $base_dn, $search_filter, $attributes=null)
{
if(!extension_loaded('ldap'))
{
echo "This php version does not seem comptible with LDAP. Please install the
php5-ldap module";
Yii::app()->end();
}
if (!($connect = @ldap_connect("ldaps://ldap.unil.ch", 636)))
{
echo "Unable to connect to server ".$server."";
Yii::app()->end();
}
if ($version == 3)
{
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
}
if (!(@ldap_bind($connect, $auth_user, $auth_pass)))
{
return false;
}
...
...
}
My problem:
The "ldap_bind" function always returns false.
I'm sure about username, password and LDAP adress informations (I tried them in a LDAP client GUI). The apache "ssl_module" is activated.
I'm aware I have to manage something with the LDAP server certificate. I've spent time on google but I am still stuck on this problem.
So, Could anyone tell me how to succeed this connection?.
I faced the same problem, for me the solution was to add a port to the server