私は 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());
}