尝试使用URL('ldap:// hostname /')尝试从具有PHP5的Ubuntu服务器连接到LDAP服务器时出现问题。 当我不使用URL格式($server = 'hostname'
)时,代码正常工作。使用URL的PHP LDAP连接
代码:
$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!!!';
}
}
编辑:
我需要ldaps
,但我看到了与我ldap
有同样的问题。虽然与ldap相关的问题是通过在URL中添加端口来解决的,但我仍然遇到了ldaps问题。无论如何,通过仅使用主机名(无URL格式)连接后,我设法绕过ldap_start_tls (resource $link)
。
你是什么意思*当我不使用URL *的代码工作正常? – Raptor
@shivan:我的意思是它仅在使用主机名时不起作用,不使用URL格式。 – Mihai