Page MenuHomePhorge

Fatal error: Uncaught Error: Cannot access private property LDAP::$domain
Closed, ResolvedPublic

Description

There's a bug in Net_LDAP3 used by Kolab Webadmin

I'm using up2date packages from kolab-webadmin (commit 180a93bcd7d6 ) and php-net-ldap3 (commit 39a754269fe6)

Here's the Fatal Error message

[25-Mar-2025 22:46:58 UTC] PHP Fatal error:  Uncaught Error: Cannot access private property LDAP::$domain in /usr/share/php/Net/LDAP3.php:970
Stack trace:
#0 /usr/share/php/Net/LDAP3.php(941): Net_LDAP3->entry_find_by_attribute()
#1 /usr/share/php/Net/LDAP3.php(713): Net_LDAP3->entry_dn()
#2 /usr/share/kolab-webadmin/lib/Auth/LDAP.php(551): Net_LDAP3->effective_rights()
#3 /usr/share/kolab-webadmin/lib/Auth.php(285): LDAP->effective_rights()
#4 /usr/share/kolab-webadmin/lib/api/kolab_api_service_user.php(215): Auth->list_rights()
#5 /usr/share/kolab-webadmin/lib/kolab_api_controller.php(176): kolab_api_service_user->user_effective_rights()
#6 /usr/share/kolab-webadmin/public_html/api/index.php(33): kolab_api_controller->dispatch()
#7 {main}
  thrown in /usr/share/php/Net/LDAP3.php on line 970

The Problem:

The method Net_LDAP3::entry_find_by_attribute() tries to access an undefined attribute $this->domain (as for Net_LDAP3).
--> https://git.kolab.org/diffusion/PNL/browse/master/lib/Net/LDAP3.php;39a754269fe6e5d94b0fe87215e89232876bda01$970

This attribute ($this->#domain) is defined as private
--> https://git.kolab.org/diffusion/WAP/browse/master/lib/Auth/LDAP.php;180a93bcd7d61557b8f504f163b0c1ca1532234a$31

Variante 1:
A variable used in Net_LDAP3 (which is not an abstract class) should be defined as protected.

Variante 2:
The use of the undefined variable $this->domain in a debug message should be removed or change somehow.

Workaround (lib/Auth/LDAP.php) ... not ideal, but at least it doesn't throw a Fatal Error anymore.

/**
 * Kolab LDAP handling abstraction class.
 */
class LDAP extends Net_LDAP3 {
    private $conf;
    protected $domain; # Change from private to protected
    private $_ldap_uri;
    private $_ldap_port;
    private $_ldap_scheme;
    private $sort_result_key;

Details

Ticket Type
Task