首页 > 解决方案 > 使用 PHP 连接活动目录或 LDAP

问题描述

我正在尝试将窗口的活动目录或 LDAP 与用PHP 制作的应用程序 ( GLPI ) 连接起来。

连接参数:

与服务器连接:

$ds = ldap_connect($host, $port) // return true

@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

@ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

@ldap_set_option($ds, LDAP_OPT_DEREF, $deref_options);

将连接与服务器以及用户和密码相关联

ldap_bind ($ds, $ login, $ password)

返回我:

“无法联系 LDAP 服务器”

我想知道该错误消息会发生什么,因为在第一种方法中它向我返回 true,这意味着如果它连接到服务器。

RootDN这很好,并且拥有我正在使用的用户的所有权限。

默认服务器很好,我做到了pingtelnet.

注意:我已经下载了 LDAPExplorer 并建立了连接没有问题。

标签: phpwindowsldap

解决方案


是否缺少 :$ds = ldap_connect ...就像它在您的代码中一样?

它应该是这样的:

$ds = ldap_connect($host, $port);

@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

@ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

@ldap_set_option($ds, LDAP_OPT_DEREF, $deref_options);

ldap_bind ($ds, $login, $password)

推荐阅读