Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中使用PEAR LDAP2连接到LDAP_Php_Ldap_Pear - Fatal编程技术网

在PHP中使用PEAR LDAP2连接到LDAP

在PHP中使用PEAR LDAP2连接到LDAP,php,ldap,pear,Php,Ldap,Pear,我对使用LDAP不是很有经验,一直在研究一些堆栈溢出问题,并试图将一些代码拼凑在一起 我在php中使用PEAR LDAP2包。到目前为止,我已经设置了我的过滤器,但我还没有搜索任何东西 我所要做的就是设置与服务器的连接,但当我的代码达到: $ldap= Net_LDAP2::connect($config); 脚本冻结并生成一个白色屏幕。我怎样才能解决这个问题 脚本如下: <?php include '../config/connection.php'; require_once '.

我对使用LDAP不是很有经验,一直在研究一些堆栈溢出问题,并试图将一些代码拼凑在一起

我在php中使用PEAR LDAP2包。到目前为止,我已经设置了我的过滤器,但我还没有搜索任何东西

我所要做的就是设置与服务器的连接,但当我的代码达到:

$ldap= Net_LDAP2::connect($config);
脚本冻结并生成一个白色屏幕。我怎样才能解决这个问题

脚本如下:

<?php

include '../config/connection.php';
require_once '../Scripts/Net_LDAP2-2.0.12/Net/LDAP2/LDAP2.php';

//retrieve information from the form
$username = $_POST['username'];
$password = $_POST['password'];

$usernamefilter = Net_LDAP2_Filter::create('username', 'equals', $username);
$passwordfilter = Net_LDAP2_Filter::create('password', 'equals', $password);
$combinedFilter =  Net_LDAP2_Filter::combine('and', array($usernamefilter, $passwordfilter));

echo "filters have been created. <br />";

// The configuration array:
$config = array (
    'binddn'    => 'username',
    'bindpw'    => 'password',
    'basedn'    => 'ou=People,dc=campus,dc=aston,dc=ac,dc=uk',
    'host'      => 'gc.campus.aston.ac.uk',
'filter'    => $combinedFilter
);

echo "config array has been set up. <br />";

// Connecting using the configuration:
$ldap = Net_LDAP2::connect($config);

echo "connection to ldap has been sent. <br />";

// Testing for connection error
if (PEAR::isError($ldap)) {
    die('Could not connect to LDAP-server: '.$ldap->getMessage());
}

考虑使用已知良好的客户端验证LDAP目录服务器是否正确响应LDAP客户端请求<供应商分发的code>ldapsearch
是执行此任务的最佳选择。执行以下搜索以验证服务器是否正在接受连接客户端连接并响应:

ldapsearch -h gc.campus.aston.ac.uk -p <your-port> \
   -D the-distinguished-name -w password \
   -b 'ou=People,dc=campus,dc=aston,dc=ac,dc=uk' \
   -s base '(&)' 1.1
ldapsearch-h gc.campus.aston.ac.uk-p\
-D可分辨名称-w密码\
-b'ou=人,dc=校园,dc=阿斯顿,dc=交流,dc=英国'\
-s基“(&)”1.1
如果此操作挂起、失败或未返回任何条目,请更正问题并重新测试,直到上述命令成功

注意:如果您使用的是旧的传统OpenLDAP ldapsearch,请添加-x命令行选项