`ldap_search` not working on debian 11 with PHP8.2 and ldap module compiled from source
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lỗi ldap_list trong bản build Docker Debian 11 PHP 8.2, sử dụng các đường dẫn ldap_connect, ldap_bind, ldap_read và ldap_get_entries được mô tả trong báo cáo. So sánh module đã biên dịch với module Ubuntu đang hoạt động và ldapsearch trên dòng lệnh, sau đó ghi lại một khác biệt đã được xác nhận về package hoặc compiler và xác minh rằng tìm kiếm LDAP trả về các entry.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, php
- Lĩnh vực
- authentication, backend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100