Php 更改LDAP的端口
我正在尝试连接到LDAP。我知道默认端口是389,但我们已将其更改为636 我有这部分代码Php 更改LDAP的端口,php,ldap,Php,Ldap,我正在尝试连接到LDAP。我知道默认端口是389,但我们已将其更改为636 我有这部分代码 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($li
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.");
}
有没有办法添加新端口?我试过了
$link_id = ldap_connect(self::$HOST,"636");
但不起作用。不推荐使用带有两个参数的$host
和$port
(端口也应为整数)
正确的函数签名是:
ldap_connect ( string|null $uri = null ) : resource|false
LDAP URI应该类似于ldap://hostname:port
或ldaps://hostname:port
使用SSL加密时:
$link_id = ldap_connect('ldap://' . self::$HOST . ':636');
非常感谢你!你知道ldap和U绑定是否也发生了变化吗?我的密码里有这个$bind\u result=ldap\u bind($link\u id,self:$APP\u DN,self:$SERVER\u PASSWORD);没有ldap_bind()未更改,如果无法绑定,请先检查连接,@参见示例。