0
我对使用LDAP并不是很有经验,并且一直在研究几个堆栈溢出问题,并试图将一些代码拼凑在一起。在PHP中使用PEAR LDAP2连接到LDAP
我使用PEAR LDAP2包与我的PHP。到目前为止,我已经设置了我的过滤器,但我还没有搜索任何东西。
所有我想要做的是建立我与服务器的连接,但是当我的代码达到:
$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());
}