snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.21k stars 3.2k forks source link

LDAP connection fails with multiple servers after upgrade from 4.9.5 to 5.1.4 #9348

Open AJDurant opened 3 years ago

AJDurant commented 3 years ago

Please confirm you have done the following before posting your bug report:

Describe the bug Previously I had multiple ldap servers listed in my settings: ldap://dc00.example.com ldap://dc01.example.com

This is allowed in the standard php_ldap connection, and will automatically fail-over when connecting if the first is unavailable. However, with the changes to the LDAP backend in v5 this string is no longer valid, and I get an exception:

   ErrorException  : ldap_connect(): Could not create session handle: Bad parameter to an ldap routine

  at /var/www/snipeit/vendor/adldap2/adldap2/src/Connections/Ldap.php:264
    260|
    261|         // Reset the bound status if reinitializing the connection.
    262|         $this->bound = false;
    263|
  > 264|         return $this->connection = ldap_connect($this->host);
    265|     }
    266|
    267|     /**
    268|      * {@inheritdoc}

  Exception trace:

  1   ldap_connect("ldap://dc00.example.com ldap:389")
      /var/www/snipeit/vendor/adldap2/adldap2/src/Connections/Ldap.php:264

  2   Adldap\Connections\Ldap::connect()
      /var/www/snipeit/vendor/adldap2/adldap2/src/Connections/Provider.php:121

To Reproduce Steps to reproduce the behavior:

  1. Set ldap server to multiple server names
  2. Do anything with ldap - in my case it was running php artisan up after fixing some db migrations.
  3. See exception

Expected behavior Host string is correctly passed to ldap_connect allowing multiple servers.

Server (please complete the following information):

Error Messages See trace above

Additional context

Workaround, edit the ldap_server setting in the db, to only have one host and now I can use Snipe-IT again, but without ldap server connection fail-over.

welcome[bot] commented 3 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.