This repository was archived by the owner on Jul 24, 2023. It is now read-only. 
 -   Notifications  You must be signed in to change notification settings 
- Fork 194
 This repository was archived by the owner on Jul 24, 2023. It is now read-only. 
 OpenLDAP + NoDatabaseUserProvider its not working #755
Copy link
Copy link
Open
Description
- Laravel Version: 5.5
- Adldap2-Laravel Version: 4.0
- PHP Version: 7.0.9
- LDAP Type: OpenLDAP
Description:
I'm trying to connect on a OpenLDAP + NoDatabaseUserProvider but always return false. So, looking into the code i could see this:
Adldap2-Laravel/src/AdldapServiceProvider.php
Line 111 in e7a88e0
| $provider->connect(); | 
and this:
So the script will always go throught bindAsAdministrator method. If there is no issue on that, what i'm doing wrong?
But when i try by ldap function directly, its works:
$username = 'username1234'; $password = 'password1234'; $ldap_usr_dom = '@hostname.com'; $ldap_dn = "DC=echo,DC=quinstreet,DC=net"; $ldap_host = 'my.hostname.com'; $ldap = ldap_connect($ldap_host); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); // verify user and password if ($bind = @ldap_bind($ldap, $username . $ldap_usr_dom, $password)) { echo "binded"; $filter = "(sAMAccountName=" . $username . ")"; $attr = array("memberof"); $result = ldap_search($ldap, $ldap_dn, $filter, $attr) or exit("Unable to search LDAP server"); $entries = ldap_get_entries($ldap, $result); ... } else { echo "Not-binded"; }I cant upgrade PHP version and Laravel version yet.
Steps To Reproduce:
route/web.php:
Auth::routes(['reset' => false, 'verify' => false, 'register' => false]);config/auth.php:
return [ 'defaults' => [ 'guard' => 'ldap', ... ], 'guards' => [ 'ldap' => [ 'driver' => 'session', 'provider' => 'ldap' ], ... ], 'providers' => [ 'ldap' => [ 'driver' => 'adldap', ] ... ] ];config/adldap.php:
return [ ... 'connections' => [ 'default' => [ ... 'schema' => Adldap\Schemas\OpenLDAP::class, ] ] ]config/adldap_auth.php:
return [ 'provider' => Adldap\Laravel\Auth\NoDatabaseUserProvider::class, 'usernames' => [ 'ldap' => [ 'discover' => 'username', 'authenticate' => 'distinguishedname', ], ], 'rules' => [ Adldap\Laravel\Validation\Rules\DenyTrashed::class, ] 'scopes' => [], ]app\http\controllers\logincontroller.php@LoshowLoginForm:
public function showLoginForm() { $credentials = [ 'username' => 'username1234', 'password' => 'password1234', ]; var_dump(Auth::guard()->attempt($credentials)); exit; }Thank You