PHPackages                             dgild/multi-connector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dgild/multi-connector

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dgild/multi-connector
=====================

Authentication with DB and LDAP in Laravel

0143PHP

Since Apr 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Gildus/multi-connector)[ Packagist](https://packagist.org/packages/dgild/multi-connector)[ RSS](/packages/dgild-multi-connector/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

MultiConnector
==============

[](#multiconnector)

It uses ADLDAP 5.0 library forked on Adldap2 () to create a bridge between Laravel and LDAP

> Originally written by Sarav. Adopted by the community.

Installation
------------

[](#installation)

1. Install this package through Composer for Laravel v5.1:

    ```
    composer require dgild/multi-connector:dev-master
    ```
2. Add the service provider in the app configuration by opening `config/app.php`, and add a new item to the providers array.

    ```
    ```
    Dgild\MultiConnector\MultiConnectorServiceProvider::class
    ```

    ```

    Them you need to comment the line:

    ```
    Illuminate\Auth\AuthServiceProvider::class

    ```
3. Change the authentication driver in the Laravel config to use the ldap driver. You can find this in the following file `config/auth.php`

    ```
    'driver' => 'eloquent',
    ```

    By

    ```
    'multi' => [
    	'db' => [
    		'driver' => 'eloquent',
    		'model'  => App\User::class,
    		'table'  => 'users'
    	],
        'ldap' => [
    		'driver' => 'ldap',
    		'model'  => Dgild\MultiConnector\Model\User::class,
    		'table'  => 'users'
    	],
    ],
    ```
4. Publish a new configuration file with `php artisan vendor:publish` in the configuration folder of Laravel you will find `config/ldap.php` and modify to your needs. For more detail of the configuration you can always check on [ADLAP documentation](http://adldap.sourceforge.net/wiki/doku.php?id=documentation_configuration)

    ```
    return array(
        'plugins' => array(
            'adldap' => array(
                'account_suffix'=>  '@domain.local',
                'domain_controllers'=>  array(
                    '192.168.0.1',
                    'dc02.domain.local'
                ), // Load balancing domain controllers
                'base_dn'   =>  'DC=domain,DC=local',
                'admin_username' => 'admin', // This is required for session persistance in the application
                'admin_password' => 'yourPassword',
            ),
        ),
    );

    ```

    Please note that the fields 'admin\_username' and 'admin\_password' are required for session persistance!

Usage
-----

[](#usage)

The LDAP plugin is an extension of the Auth class and will act the same as normal usage with Eloquent driver.

For example if you need to login with Eloquent:

```
\Auth::attempt('db', $credentials, $request->has('remember'));

```

Or if you need to login with Ldap:

```
\Auth::attempt('ldap', $credentials, $request->has('remember'));

```

Them you need to modify /app/Http/Controllers/Auth/AuthController.php like these:

```
