我在本地使用 LinuxMint 工作,并在 virtualbox 中安装了带有 openldap 的 UbuntuServer。现在我按照本指南配置 http://help.ubuntu-it.org/12.04/server/serverguide/it/ubuntu-1204-server.pdf TLS/SSL 身份验证。我已经在客户端(linuxmint)中安装了 Xampp,并使用以下命令配置 /etc/ldap/ldap.conf:
TLS_CACERT /etc/ssl/certs/192.168.1.46_slapd_cert.pem
TLS_REQCERT never
我尝试连接php函数:
<?php
// This code goes directly to the 636 SSL port
$ldaphost = "ldaps://192.168.1.46";
$ldapUsername = "cn=admin,dc=company,dc=com";
$ldapPassword = "secret";
$ds = ldap_connect($ldaphost);
if(!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
print "Could not set LDAPv3\r\n";
}
else {
// now we need to bind to the ldap server
$bth = ldap_bind($ds, $ldapUsername, $ldapPassword) or die("\r\nCould not connect to LDAP server\r\n");
}
?>
但不起作用..
如果我在终端中尝试:
ldapsearch -x -H ldaps://192.168.1.46 -b "cn=company,cn=com"
有用!!但是通过 php 为什么?..我尝试在 /opt/lampp/etc/openldap 中配置 ldap.conf 但没有结果..