【问题标题】:LDAP Authentication on WindowsWindows 上的 LDAP 身份验证
【发布时间】:2012-11-15 09:14:59
【问题描述】:

我安装了 64 位 Windows 平台和 Postgresql 8.4(因为 Apache,EnterpriseDB-ApachePHP 安装在 Pstgres 上)。我需要使用 Active Directory(或 LDAP?)凭据对系统进行身份验证,但即使我启用了 LDAP 和在 error 日志上重新启动 Apache 我看到 PHP 致命错误:在 path/to/my/phpfile 中调用未定义函数 ldap_connect().. PHP我使用的脚本如下,

<?php

$user = $_POST["myUserName@mydomain.com"];
$pass = $_POST["muPassword"];
//in our system, we already use this account for LDAP authentication on the server above
$ldap_serv = 'ldap://192.168.69.10';
$ldap_port = '389';
$lc = ldap_connect($ldap_serv, $ldap_port);
ldap_set_option($lc, LDAP_OPT_REFERRALS, 0);
ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, 3);
$ldapbind = ldap_bind($lc,$user,$pass);
if ($ldapbind == false) {
  echo 'username or password is wrong';
}
else
{
echo "You Logged in";
echo "<br><br><br>Wellcome<br><br><br>";
}
?>

【问题讨论】:

    标签: php apache authentication ldap


    【解决方案1】:

    使用 LDAP 函数需要 PHP LDAP 扩展。只需检查它是否在您的 php.ini (extension=php_ldap.dll) 中未注释

    【讨论】:

    • 我卸载了 postgres 并安装了 WAMP,取消注释该行并且它工作正常
    • 当我看到 php.ini 文件时,这个 (extension = php_ldap.dll) 不存在,我只是添加了这一行并启用了 ldap。
    【解决方案2】:

    显然没有加载 PHP 扩展。有几件事可以尝试:

    • 从命令行运行“php -m”并确保 ldap 在模块列表中,并且没有与 ldap 相关的错误。
    • 确保 apache php 模块正在使用您修改的 php.ini(并在页面上查找 php.ini)

    【讨论】:

    • @dealby 很好的答案,但我不能从命令行朗姆酒'php -m'。我正在使用 Postgresql(它位于 Apache 的一个版本上)。我正在取消注释 Postgres 中 Apache 的 php.ini 的扩展
    • @ilis 这让我很困惑.... Postgres 是您的数据库 - 我不确定您所说的 Apache 是什么意思。从理论上讲,apache 使用 php 模块来解释您的脚本并提供结果。然后通常还有 php.exe,它允许您从命令行运行 php 脚本。当您运行具有 phpinfo(); ?> 在吗? apache 日志中是否有关于未加载 php ldap 模块的任何内容?
    • 对不起,我的意思是 Apache 是 Postgresql 的一部分,我没有安装任何其他 Apache 或 PHP 模块,我尝试了 phpinfo() 但几乎没有关于 ldap 的内容,这意味着它没有被激活。跨度>
    • 在 phpinfo() 输出中,您是否看到您修改过的 php.ini 文件?你能检查你的 apache 日志以确保它重新启动时没有错误吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-03
    • 2011-09-23
    • 2017-01-09
    相关资源
    最近更新 更多