Reputation: 1936
I am trying to connect to LDAP. I know that default port is 389 but we have changed it to 636.
I have this part of code
private static $HOST = "mywebpage.com";
// Connect to LDAP
$link_id = ldap_connect(self::$HOST);
$bind_result = ldap_bind($link_id, self::$APP_DN, self::$SERVER_PASSWORD);
error_log(print_r($link_id,true)); //returns resource id #6
error_log(print_r($bind_result,true)); //returns 1
if (!$bind_result)
{
error_log("Failed to bind to LDAP server.");
throw new RuntimeException("Failed to bind to LDAP server.");
}
Is there any way to add the new port somehow? I tried
$link_id = ldap_connect(self::$HOST,"636");
But didn't work.
Upvotes: 0
Views: 351
Reputation: 16095
The use of ldap_connect()
with 2 parameters $host
and $port
is deprecated (also the port should be an integer).
The correct function signature is :
ldap_connect ( string|null $uri = null ) : resource|false
An LDAP URI should look like ldap://hostname:port
or ldaps://hostname:port
when using SSL encryption :
$link_id = ldap_connect('ldap://' . self::$HOST . ':636');
Upvotes: 1