2017 © Pedro Peláez
 

library ldap-connector

Easily authenticate with LDAP in Laravel

image

dsdevbe/ldap-connector

Easily authenticate with LDAP in Laravel

  • Sunday, December 4, 2016
  • by Dsdevbe
  • Repository
  • 10 Watchers
  • 105 Stars
  • 6,925 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 28 Forks
  • 4 Open issues
  • 13 Versions
  • 1 % Grown

The README.md

Not maintained anymore

I've created this project during my internship for an easy authentication between various applications within my company. The scope of the ldap-connector was only to authenticate with Laravel to the LDAP server., (*1)

In case you're looking for a replacement please checkout Adldap2-Laravel. They have also created the awesome library Adldap2 which ldap-connector was using., (*2)

I'll stop maintaining this project but would like to thank all the people that contributed or used this project., (*3)

Ldap-connector

Build Status Latest Stable Version Total Downloads License, (*4)

Provides an solution for authentication users with LDAP for Laravel 5.x. It uses ADLDAP library on Adldap2 to create a bridge between Laravel and LDAP, (*5)

Installation

Laravel 5.1 - 5.0

  1. Install this package through Composer by adding the following line to composer.json, (*6)

        "dsdevbe/ldap-connector": "3.0.*"
    

    or you could use command-line js composer require "dsdevbe/ldap-connector:3.0.*", (*7)

  2. Add the service provider in the app configuration by opening config/app.php, and add a new item to the providers array., (*8)

    Dsdevbe\LdapConnector\LdapConnectorServiceProvider::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, (*9)

    'driver' => 'ldap',
    
  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, (*10)

    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!, (*11)

Usage

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

if (Auth::attempt(array('username' => $username, 'password' => $password)))
{
    return Redirect::intended('dashboard');
}

You can find more examples on Laravel Auth Documentation on using the Auth:: function., (*13)

Use AuthController

If you want to use the authentication controller that ships with Laravel you will need to change the following files. By default App\Http\Controllers\Auth\AuthController checks for the email field if nothing is provided. To overwrite this value add the following line in the AuthController., (*14)

protected $username = 'username';

Laravel documentation: Authentication Quickstart, (*15)

Ldap Groups

  • Auth::user()->getGroups() returns array with groups the current user belongs to.
  • Auth::user()->inGroup('GROUPNAME') returns boolean if user belongs to GROUPNAME

Ldap User Information

  • Auth::user()->getUsername() returns authenticated username.
  • Auth::user()->getFirstname() returns authenticated first name.
  • Auth::user()->getLastname() returns authenticated last name.
  • Auth::user()->getEmail() returns authenticated email address.

Laravel 5.2 - ...

  1. Install this package through Composer by adding the following line to composer.json, (*16)

    "dsdevbe/ldap-connector": "4.0.*"
    

    or you could use command-line, (*17)

    composer require "dsdevbe/ldap-connector:4.0.*"
    
  2. Add the service provider in the app configuration by opening config/app.php, and add a new item to the providers array., (*18)

    Dsdevbe\LdapConnector\LdapConnectorServiceProvider::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, (*19)

    'providers' => [
        'users' => [
            'driver' => 'ldap',
            'adldap' => [
                '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!, (*20)

Usage

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

if (Auth::attempt(array('username' => $username, 'password' => $password)))
{
    return Redirect::intended('dashboard');
}

You can find more examples on Laravel Auth Documentation on using the Auth:: function., (*22)

Use AuthController

If you want to use the authentication controller that ships with Laravel you will need to change the following files. By default App\Http\Controllers\Auth\AuthController checks for the email field if nothing is provided. To overwrite this value add the following line in the AuthController., (*23)

protected $username = 'username';

Laravel documentation: Authentication Quickstart, (*24)

Ldap User Information

Difference with ldap-connector V3 is that now the adLDAP model is directly exposed on the user model. This means that you can fetch all data directly from the user. To access the adldap model you can use now Auth::user()->getAdLDAP()., (*25)

Examples: - Auth::user()->getAdLDAP()->getAccountName() - Auth::user()->getAdLDAP()->getFirstName(), (*26)

To fetch more properties please check adLDAP2 documentation, (*27)

Contributing

Feel free to contribute to this project for new features or bug fixes. We are open for improvements!, (*28)

The Versions

04/12 2016

dev-master

9999999-dev https://github.com/SaschaDens/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by SaschaDens

laravel ldap

14/05 2016

dev-Laravel4.2

dev-Laravel4.2 https://github.com/dsdevbe/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

by Avatar Dsdevbe

laravel ldap

16/04 2016

4.0.1

4.0.1.0 https://github.com/SaschaDens/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by SaschaDens

laravel ldap

16/04 2016

dev-PasswordValidation

dev-PasswordValidation https://github.com/SaschaDens/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by SaschaDens

laravel ldap

28/03 2016

dev-Laravel5.1

dev-Laravel5.1 https://github.com/SaschaDens/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by SaschaDens

laravel ldap

01/03 2016

4.0.0

4.0.0.0 https://github.com/SaschaDens/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by SaschaDens

laravel ldap

12/12 2015

3.1.1

3.1.1.0 https://github.com/SaschaDens/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by SaschaDens

laravel ldap

02/08 2015

3.1.0

3.1.0.0 https://github.com/SaschaDens/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

by SaschaDens

laravel ldap

26/02 2015

3.0.2

3.0.2.0 https://github.com/dsdevbe/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

by Avatar Dsdevbe

laravel ldap

22/02 2015

3.0.1

3.0.1.0 https://github.com/dsdevbe/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

by Avatar Dsdevbe

laravel ldap

06/02 2015

3.0.0

3.0.0.0 https://github.com/dsdevbe/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

by Avatar Dsdevbe

laravel ldap

28/10 2014

2.0.0

2.0.0.0 https://github.com/dsdevbe/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

by Avatar Dsdevbe

laravel ldap

22/04 2014

1.0.0

1.0.0.0 https://github.com/dsdevbe/ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Dsdevbe

laravel ldap