我正在尝试使用 PHP 使用 LDAP 身份验证。
下面是我的代码:
<?php
$ldaphost = 'ldap://ldapServer';
$ldapport = 389;
$ds = ldap_connect($ldaphost, $ldapport)
or die("Could not connect to $ldaphost");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
//ldap_set_option($ds, LDAP_OPT_DEBUG_LEVEL, 7);
if ($ds)
{
$username = "testuser@domain.com";
$upasswd = "testpass";
$ldapbind = ldap_bind($ds, $username, $upasswd);
if ($ldapbind)
{print "Congratulations! $username is authenticated.";}
else
{print "Access Denied!";}
}
?>
但它会引发以下错误:
PHP 警告::
ldap_bind()
无法绑定到服务器:无法联系 LDAP 服务器
知道如何解决它吗?
注意:ldap.config
当我在某个论坛上遇到这个术语时,我们是否需要在某个地方归档。我在我的机器上没有看到任何这样的文件。我php_ldap.dll
在 ext 文件夹中并使用Windows
.