ainme / laravel5-ldap by aimme

Ldap (Active Directory) authentication for Laravel 5
29
0
2
Package Data
Maintainer Username: aimme
Maintainer Contact: muhammadhu.aiman@gmail.com (Mohamed Aiman)
Package Create Date: 2016-11-09
Package Last Update: 2016-11-11
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:16:28
Package Statistics
Total Downloads: 29
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Build Status Built for Laravel 5 MIT License

  • Tested only on Laravel 5.3
  • You will need to have user Eloquent Model, and the database users table should have email field
  • You could use both default Auth and Ldap
  • Ldap facade works as Auth. Its the gate for ldap authentication
  • Users should be in the providers (in this case users) table and Active Directory, password field is not required.
  • See below to configure provider

####Installation

1 - Require this package with composer:

composer require aimme/laravel5-ldap

2 - add provider

file: config/app.php

'providers' => [
    ....
    Aimme\Ldap\LdapServiceProvider::class,
];

3 - add alias

file: config/app.php

'aliases' => [
    ....
    'Ldap' => Aimme\Ldap\Facades\Ldap::class,
    ....
];

4 - run these artisan commands

php artisan make:ldap-auth

php artisan vendor:publish --provider="Aimme\Ldap\LdapServiceProvider"

5 - add middleware

file: app/Http/Kernel.php

protected $routeMiddleware = [
    ...
    'ldap' => \Aimme\Ldap\Middleware\Authenticate::class,
    ...
];

6 - bring following configuration changes to the ldap config file

file: config/ldap.php

  • change providers array users model to your Eloquent user model path if it's different

    ~~~~ 'providers' => [ 'users' => [ 'driver' => 'ldap', 'model' => App\User::class, ], ~~~~

  • set your environment variables.

    ~~~~ 'domain' => env('LDAP_DOMAIN', 'MYDOMAIN'), 'host' => env('LDAP_HOST', 'ldap://aimme.mydomain.net'), ~~~~

See http://php.net/manual/en/function.ldap-connect.php

  • host(LDAP_HOST) is the $host eg: ldap://aimme.mydomain.net

See http://php.net/manual/en/function.ldap-bind.php

  • domain(LDAP_DOMAIN) is the $bind_rdn example: MYDOMAIN