Adldap2 / Adldap2-Laravel

LDAP Authentication & Management for Laravel
MIT License
911 stars 184 forks source link

can't contact ldap server on production server, works fine on Test server #913

Closed MAELALE closed 3 years ago

MAELALE commented 3 years ago

I deploy my laravel code on 2 similar servers (red hat 8 with apache server). One is for tests the other one is for the production. I have no trouble on the testing server, my laravel code with adldap2 works fine, but I have the error "Can't contact ldap server" on the production server:

local.DEBUG: AuthenticatesUsers::attemptLogin {"BindException":"[object] (Adldap\Auth\BindException(code: -1): Can't contact LDAP server at /data/Myproject/vendor/adldap2/adldap2/src/Auth/Guard.php:107)

1) On both servers I succeed to connect to my ldap through command line with this kind of command:

ldapsearch -x -H ldap://myldap.com -D "LDAP_USERNAME" -W -b "my LDAP_BASE_DN" cn

2) My .env file is the same on both servers. I'll try with SSL or TLS without success (the both protocols works fine on my testing server)

3) The ldap.conf file are the same on both servers.

4) I clear all artisan caches on both servers in order to be sure that last parameters from .env file are set:

php artisan config:cache php artisan config:clear php artisan cache:clear

5) I create a little php script to check ldap connection through php command and it's works (Successfully connected to LDAP !) on the both server too:

$ldapconn = ldap_connect("ldap://myldap.com") or die("Impossible to connect to the LDAP server."); $ldapbind = ldap_bind($ldapconn, 'LDAP_USERNAME', 'LDAP_PASSWORD'); // check binding if ($ldapbind) { echo "Successfully connected to LDAP !" . PHP_EOL; $dn = 'LDAP_BASE_DN'; $sr = ldap_list($ldapconn, $dn, 'cn=*'); if (false === $sr) { die('Impossible to use the dn: ' . $dn . PHP_EOL); } $info = ldap_get_entries($ldapconn, $sr); if ($info['count'] === 0) die('No entries :('); for ($i=0; $i < $info["count"]; $i++) { echo $info[$i]["cn"][0] . PHP_EOL; } } else { $var = ''; ldap_get_option($ldapconn, LDAP_OPT_ERROR_STRING, $var); echo "Connection to LDAP failed..." . PHP_EOL . $var . PHP_EOL; }

what other points between the 2 servers I could check to solve my problem?

MAELALE commented 3 years ago

switch to Adldap2 page: https://github.com/Adldap2/Adldap2/issues/790