php / php/php-src

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

未关闭
#18,832 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: ldap Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 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 摘要。