php / php/php-src

`ldap_search` not working on debian 11 with PHP8.2 and ldap module compiled from source

オープン
#18,832 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Extension: ldap Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

The following code:

Hey, I use a self compiled php8.2-ldap extension in an php8.2 setup (Default PHP8.2 container from docker php 8.2.28-cli-bullseye) .
The following code always return the ldap error Operations error (ldap_error-code 1)

<?php
$ldap_host = "myhost"; 
$ldap_dn = "DC=host,DC=site";
$ldap_username = <user>; 
$ldap_password = <pw>; 
$options = [
        'host' => $ldap_host,
        'dn' => $ldap_dn,
        'username' => $ldap_username,
        'password' => $ldap_password,
];


$ldapconn = ldap_connect($options['host']);
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);

@ldap_bind($ldapconn, $options['user'], $options['password']);

$filter = "(objectClass=*)";

@$search = ldap_list($ldapconn, $dn, $filter);

if (!$search) {
        var_dump([
                '$search' => $search,
                'error' => 'LDAP search failed',
                'ldap_error' => ldap_error($ldapconn),
                'ldap_errno' => ldap_errno($ldapconn),
                'base_dn' => $dn,
                'filter' => $filter
        ]);
}
ldap_unbind($ldapconn);

?>

ldap_connect and ldap_bind are working fine. It is also possible to get the base dn using the following codeblock:

$read = ldap_read($ldapconn, '', 'objectClass=*', ['defaultNamingContext'], 0);
$data = ldap_get_entries($ldapconn, $read);
$dn = $data[0]['defaultnamingcontext'][0] ?? null;

That means ldap_read and ldap_get_entriesare working.

If I use the same code from above on ubuntu using pre-compiled php8.2-ldap.so module from ubuntu repository, the code runs fine without any errors. So I can be sure, that the the credentials from $options are correct. Also an ldapsearch from command line with the same credentials and filters returns valid results.

I compile the php8.2-ldap module during docker-build phase using that code:

RUN apt-get update && apt-get -y install pkg-config [...] ldap-utils libldap-common libldap2-dev\
[...]
&& docker-php-ext-configure ldap --with-libdir=/lib/x86_64-linux-gnu/ \
&& docker-php-ext-install ldap \
[...]

Resulted in this output:

`Operations error`  (ldap_error-code 1)

But I expected this output instead:

I expected a list of LDAP entries

Any idea, what's goinig on here? Did a miss a compiler-option or an package?

PHP Version
PHP 8.2.4 (cli) (built: Mar 16 2023 21:25:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.4, Copyright (c), by Zend Technologies
Operating System

Debian 11

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、レポートで説明されている ldap_connect、ldap_bind、ldap_read、ldap_get_entries のパスを使用して、Debian 11 PHP 8.2 Docker ビルドで ldap_list の失敗を再現します。コンパイル済みモジュールを、動作する Ubuntu モジュールおよびコマンドラインの ldapsearch と比較し、確認済みのパッケージまたはコンパイラの違いを記録して、LDAP 検索がエントリを返すことを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
docker, php
領域
authentication, backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。