[Bug] ldapToUser(): Argument #1 ($entry) must be of type array, int given

Hi,

since today I see errors when trying to log in via LDAP authentication. It’s likely that this bug exists for many days already since I just detected this due to long session cookie settings.

LibreNMS\Authentication\LdapAuthorizer::ldapToUser(): Argument #1 ($entry) must be of type array, int given, called in /opt/librenms/LibreNMS/Authentication/LdapAuthorizer.php on line 191

Connection to LDAP server works, successful authentication has been tested with ./scripts/auth_test.php.

This is daily.sh:

Clearing caches                                    OK
Updating to latest codebase                        OK
Updating Composer packages                         OK
Updating SQL-Schema                                OK
Updating submodules                                OK
Cleaning up DB                                     OK
Fetching notifications                             OK
Caching PeeringDB data                             OK

and this is validate.php:

===========================================
Component | Version
--------- | -------
LibreNMS  | 25.8.0-dev.16+50c986a64 (2025-07-28T06:07:30+02:00)
DB Schema | 2025_07_10_201918_update_vlans_table (353)
PHP       | 8.3.19
Python    | 3.11.2
Database  | MariaDB 10.11.6-MariaDB-0+deb12u1
RRDTool   | 1.7.2
SNMP      | 5.9.3
===========================================

[OK]    Composer Version: 2.8.10
[OK]    Dependencies up-to-date.
[OK]    Database Connected
[OK]    Database Schema is current
[OK]    SQL Server meets minimum requirements
[OK]    lower_case_table_names is enabled
[OK]    MySQL engine is optimal
[OK]    Database and column collations are correct
[OK]    Database schema correct
[OK]    MySQL and PHP time match
[OK]    Active pollers found
[OK]    Dispatcher Service is enabled
[OK]    Locks are functional
[OK]    No active python wrapper pollers found
[OK]    Redis is functional
[OK]    rrdtool version ok
[OK]    Connected to rrdcached

If I understand the code correctly, the function getUser() in LdapAuthorizer.php does this:

        foreach ($entries as $entry) {
            $user = $this->ldapToUser($entry);
            if ($user['user_id'] != $user_id) {
                continue;
            }

            return $user;
        }

which seems to hand over an integer to ldapToUser();
Unfortunately, same file, I see this:

/**
   * @param  array  $entry  ldap entry array
   * @return array
*/
private function ldapToUser(array $entry): array
{

So, according to the function definition, $entry is expected to be an array.

I’m no professional developer, but this looks like a mistake to me.

If I’m right, please fix this soon since no one here in my company can log in anymore and we rely on our centralized LDAP authentication. If I’m wrong, please help finding the cause for the malfunction.

I am seeing this same issue.

Also on on

./validate.php 
===========================================
Component | Version
--------- | -------
LibreNMS  | 25.8.0-dev.16+50c986a64 (2025-07-28T07:07:30+03:00)
DB Schema | 2025_07_10_201918_update_vlans_table (353)
PHP       | 8.3.23
Python    | 3.10.12
Database  | MariaDB 10.6.22-MariaDB-0ubuntu0.22.04.1-log
RRDTool   | 1.7.2
SNMP      | 5.9.1
===========================================

According to the PHP documentation. ldap_get_entries(), which is called above the code you pasted, has a single entry with the key ‘count’ instead of a numeric key with an array of values. I think this is what is tripping it up. I created a theoretical fix, but have no way to test it.

Hi!

Thanks for the patch. Just tested and it works (at least for me) :slight_smile:

I just merged it, so you should remove the patch and run ./daily.sh now :slight_smile: