在 adLDAP 中对用户进行身份验证时,结果为“用户身份验证失败”


When authenticating user in adLDAP the result is "User authentication unsuccessful"

>INFO:我正在尝试进行身份验证和 adLDAP

问题:adLDAP 告诉我"用户身份验证失败"

问题:当没有错误告诉我如何处理这个问题时,我如何找出我需要做什么。

搜索/尝试:

  1. http://adldap.sourceforge.net/faq.php
  2. stackoverflow.com/questions/2465260/using-adldap-php-class-but-getting-error-when-looking-for-group-user-belongs-to
  3. adldap.sourceforge.net/wiki/doku.php?id=documentation_examples#authenticating_a_user
  4. http://phreek.org/blog/2011/12/enable-php-ldap-module-in-xampp

法典:

require_once(dirname(__FILE__) . '/adLDAP.php');
$adldap = new adLDAP();
$username = "user";
// $username = "domain'user"; // I have also tried
$password = "pass";
$authUser = $adldap->authenticate($username, $password);
if ($authUser == true) {
  echo "User authenticated successfully";
}
else {
  echo "User authentication unsuccessful";
}
echo('<hr />');
$result=$adldap->user_info("jboyle");
print_r($result);

网页输出:

User authentication unsuccessful
Fatal error: Call to undefined method adLDAP::user_info() in C:'xampp'htdocs'adLDAP'compare.php on line 18

替换:

echo "User authentication unsuccessful";

echo "Username '{$username}' login failed: ".$adldap->getLastError();

结果:

Username 'user' login failed: Can't contact LDAP server

信息/来源:

https://sourceforge.net/projects/adldap/forums/forum/358759/topic/1719128?message=4368835http://adldap.sourceforge.net/wiki/doku.php?id=ldap_over_ssl#tell_apache_how_to_use_ldaps

做一个phpinfo()并检查HOME变量在Apache环境中指向的位置。创建一个符号链接或将 ldap.conf 复制到此位置。

如果收到连接错误,可能是因为本地 OpenSSL 安装无法识别服务器提供的证书(或其颁发机构)。这可以通过在服务器上的 ldap.conf 或类似内容中添加以下行来规避:

改变TLS_REQCERT允许永不TLS_REQCERT

Apache 必须能够读取 ldap.conf,你不能跳过这一步。