【问题标题】:How to enable LDAP authentication in PHP如何在 PHP 中启用 LDAP 身份验证
【发布时间】:2016-03-10 14:30:11
【问题描述】:

我有一台服务器(Windows Server 2012 R2),我需要在 PHP 中配置 LDAP 用户身份验证。服务器是域控制器,安装了 PHP (5.6) 并且 PHP 已经具有 LDAP 扩展。使用 ldp.exe 中的凭据绑定有效。

我知道的:

  • LDAP 连接有效
  • 我可以匿名登录
  • 我无法使用用户凭据登录(即使使用管理员凭据)
  • 我已尝试编辑策略“默认域控制器”

域控制器:LDAP 服务器签名要求

网络安全:LDAP 客户端签名要求

协商签署

PHP 代码:

// using ldap bind
$ldaprdn  = 'bigboss';     // ldap rdn or dn
$ldappass = 'AdmiN123';  // associated password

// connect to ldap server
$ldapconn = ldap_connect("ldap://172.16.31.70")
    or die("Could not connect to LDAP server.");

if ($ldapconn) {
    // binding to ldap server
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
    // verify binding
    if ($ldapbind) {
        echo "LDAP bind successful...";
    } else {
        echo "LDAP bind failed...";
    }   
}

【问题讨论】:

  • 您在 PHP 端收到任何错误消息吗?尝试ldap_error() 以获取有关实际失败的更多信息并相应地更新您的问题。这样会更容易找到解决方案。
  • 在“回显 ldap_error($ldap_bind);”什么都不返回。我在 ldp.exe 程序中尝试过 LDAP 连接。如果我连接,我必须使用“绑定凭据”绑定用户,并且简单绑定不起作用。有什么方法可以允许简单绑定?使用此 php 代码进行简单绑定应该可以工作。
  • $ldapbind 不是 $ldap_bind

标签: php active-directory ldap windows-authentication windows-server-2012-r2


【解决方案1】:

我的错,我需要编辑

$ldaprdn  = 'bigboss'

$ldaprdn  = '[domain name]\bigboss'

谢谢

【讨论】:

    猜你喜欢
    • 2019-06-10
    • 2021-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多