2017 © Pedro Peláez
 

library ldapauth

Laravel LDAP authentication wrapper

image

ptdot/ldapauth

Laravel LDAP authentication wrapper

  • Sunday, July 22, 2018
  • by didikz
  • Repository
  • 3 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel LDAP Authentication

Laravel LDAP Authentication is a package for authenticating user to Active Directory using Lightweight Directory Access Protocol and integrated with Laravel authenticatable model out of the box., (*1)

Requirements

  • Laravel 5.1 - 5.6
  • Enable PHP LDAP Extension

Installation

Install package through composer., (*2)

composer require ptdot/ldapauth

Next, if using Laravel under 5.5, include the service provider and Facade within your config/app.php file., (*3)

'providers' => [
    Ptdot\LdapAuth\LdapAuthServiceProvider::class,
],

'aliases' => [
    'LdapAuth' => Ptdot\LdapAuth\LdapAuthFacade::class,
]

Since Laravel 5.5+ is using Package Discovery, there is no need manually insert service provider and facade inside your app.php., (*4)

Configuration

Publish config using command:, (*5)

php artisan vendor:publish --tag=config

Set keys and values for your LDAP configuration in .env file., (*6)

LDAP_HOST=ldap.example.com
LDAP_PORT=389

Setup your User model or custom authentication model In config/ldap.php file and don't forget to adjust your usernameField value from your authentication model., (*7)

Make sure you are already has user data in database and create user model for authentication., (*8)

/*
    |--------------------------------------------------------------------------
    | Authentication user model
    |--------------------------------------------------------------------------
    |
    | Authentication is used User model for default.
    | Define this option if authentication model using different model / namespace.
    |
    */
    'user' => App\User::class,
    'usernameField' => 'username'

Usage

For attempting authentication using LDAP:, (*9)

$result = LdapAuth::attempt($username, $password);

Attempt method will return an array that indicate that authentication is success or not., (*10)

Example, (*11)

/**
* Logging in using LDAP
*/
public funtion login(Request $request)
{
    $username = $request->get('username');
    $password = $request->get('password');

    $login = LdapAuth::attempt($username, $password);
    if($login['status']) {
        return "Login success";
    }
    return "Login failed. Error: ".$login['message'];
}

Contributing

Feel free to report an issue or merge request if you want to help this package become better and useful., (*12)

The Versions

22/07 2018

dev-master

9999999-dev

Laravel LDAP authentication wrapper

  Sources   Download

MIT

The Requires

 

by Didik Tri Susanto

laravel authentication ldap