【问题标题】:PHP problems with LDAP searchLDAP 搜索的 PHP 问题
【发布时间】:2016-02-01 20:10:38
【问题描述】:

我不熟悉将 PHP 与活动目录和 LDAP 结合使用。我想检索用户全名,然后将其显示在页面上。 我去 PHP 的网站阅读了 ldap 语法。我在 ldap_search 遇到问题。我收到以下错误消息:

警告:ldap_search():搜索:第 18 行 C:\inetpub\wwwroot\notes\ldap_conn2.php 中的操作错误

$host = "x.x.x.x";
$port = "389";

$conn = ldap_connect($host, $port) or die ("Connected to LDAP Server!");

$bind = ldap_bind($conn) or die ("LDAP Bind successful!");

$dn = "ou=department, dn=company, dn=domain";
$filter = "(sAMAccountName=" . $user . ")";
$att = array("cn", "displayName", "givenName", "sn", "mail");
$r = ldap_search($conn, $dn, $filter, $att);

ldap_unbind($conn);

【问题讨论】:

    标签: php active-directory ldap


    【解决方案1】:

    假设您要连接的“主机”实际上正在运行 Active Directory,您的代码看起来不错。

    在 Windows 中默认不安装 AD。要运行 AD 服务器,您需要 add the Active Directory Domain Services role(假设 Windows 2008+)。

    【讨论】:

      【解决方案2】:

      我看到搜索的问题,“dn=”应该是“dc=”。之后一切正常。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-21
        • 1970-01-01
        • 1970-01-01
        • 2023-03-29
        相关资源
        最近更新 更多