2017 © Pedro Peláez
 

library laravel-ldap-connector

Authenticate with and fecth data from LDAP in Laravel

image

t3chn0crat/laravel-ldap-connector

Authenticate with and fecth data from LDAP in Laravel

  • Saturday, May 30, 2015
  • by T3chn0crat
  • Repository
  • 2 Watchers
  • 2 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

travis build, (*1)

Package

This package is a fork of dsdevbe's package (https://github.com/dsdevbe/ldap-connector)., (*2)

This package will allow you to authenticate to and fetch data from LDAP using Laravel 5.0.x., (*3)

It uses adLDAP library to create a bridge between Laravel and LDAP. adLDAP requires PHP 5 and both the LDAP and SSL libraries, (*4)

Installation

  1. Install this package through Composer for Laravel v5.0:, (*5)

    composer require T3chn0crat/laravel-ldap-connector:dev-master
    
  2. Change the authentication driver in the Laravel config to use the ldap driver. You can find this in the following file config/auth.php, (*6)

    'driver' => 'ldap',
    
  3. The config/auth.php must also have a valid model set. That model must include, (*7)

    public function getAuthIdentifier()
    {
        if (isset($this->ldap)) {
            return $this->ldap->samaccountname;
        }
    }
    
  4. Create a new configuration file ldap.php in the configuration folder of Laravel app/config/ldap.php and modify to your needs. For more detail of the configuration you can always check on adLDAP documentation, (*8)

    All of these are required, (*9)

return [
    'account_suffix'=>  "@domain.local",
    // Load balancing domain controllers, but only one is requried
    'domain_controllers'=>  [
        "192.168.0.1", 
        "dc02.domain.local"
    ],
    'base_dn'   =>  'DC=domain,DC=local',
    // AD attributes to get http://msdn.microsoft.com/en-us/library/windows/desktop/ms675090%28v=vs.85%29.aspx
    'fields' => [
        'company',
        'department',
        'displayname',
        'homephone',
        'mail',
        'memberof',
        'mobile',
        'primarygroupid',
        'samaccountname',
        'telephonenumber',
        'title',
    ]
];
  1. Once this is done you arrived at the final step and you will need to add a service provider. Open config/app.php, and add a new item to the providers array., (*10)

    'T3chn0crat\LdapConnector\LdapConnectorServiceProvider'
    

Usage

Authentication

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

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

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

Getting LDAP fields

All the LDAP fields are stored in the Auth::user()->ldap object as public properties., (*13)

Email: {{ Auth::user()->ldap->mail }}
Department {{ Auth::user()->ldap->department }}

LdapUserObject Methods

  1. isMemberOf($group)

Will test a user to see if they are a member of the passed in group. Returns a bool, (*14)

if (Auth::user()->ldap->isMemberOf('Git Hub Users')) { return 'yes'; }

Getting all users

You can use the LdapService object and getAllUsersWithFields to return a Laravel Collection of LdapUserObjects., (*15)

$ldap = App::make('T3chn0crat\LdapConnector\LdapService', [Config::get('ldap')]);
$collection = $ldap->getAllUsersWithFields();

You can now apply all the collection function to it. The results will be a collection of LdapUserObjects, (*16)

$test = $collection->where('mail', 'test@foo.com');
$department = $test->department;

The Versions

30/05 2015

dev-master

9999999-dev https://github.com/t3chn0crat/laravel-ldap-connector

Authenticate with and fecth data from LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Dsdevbe
by Avatar T3chn0crat

laravel ldap

30/05 2015

0.2-Alpha

0.2.0.0-alpha https://github.com/t3chn0crat/laravel-ldap-connector

Authenticate with and fecth data from LDAP in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Dsdevbe
by Avatar T3chn0crat

laravel ldap

22/05 2015

0.1-Alpha

0.1.0.0-alpha https://github.com/T3chn0crat/laravel-ldap-connector

Easily authenticate with LDAP in Laravel

  Sources   Download

MIT

The Requires

 

by Avatar Dsdevbe
by Avatar T3chn0crat

laravel ldap