2017 © Pedro Peláez
 

cakephp-plugin cakephp-ldap

LDAP plugin for CakePHP 3.x

image

jeffersonsimaogoncalves/cakephp-ldap

LDAP plugin for CakePHP 3.x

  • Friday, June 8, 2018
  • by jeffersonsimaogoncalves
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

LDAP Authenticate plugin

LDAP Authenticate Plugin for CakePHP 3.x and AuthComponent., (*1)

Requirements

  • CakePHP 3.6
  • php7.0-ldap module

Installation

You can install this plugin into your CakePHP application using composer., (*2)

The recommended way to install composer packages is:, (*3)

composer require jeffersonsimaogoncalves/cakephp-ldap

Usage

Include the CakeSoap library files:, (*4)

    use Ldap\Auth\LdapAuthenticate;

Configuration:

Setup the authentication class settings, (*5)

AppController Setup:

    public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Flash');
        $this->loadComponent('Auth', [
            'loginAction' => [
                'controller' => 'Users',
                'action' => 'login'
            ],
            'authError' => 'Insufficient privileges to view requested resources. Please login to continue!',
            'authenticate' => [
                'Ldap.Ldap' => [
                    'fields' => [
                        'username' => 'username',
                        'password' => 'password'
                    ],
                    'port' => Configure::read('Ldap.port'),
                    'host' => Configure::read('Ldap.host'),
                    'domain' => Configure::read('Ldap.domain'),
                    'baseDN' => Configure::read('Ldap.baseDN'),
                    'bindDN' => Configure::read('Ldap.bindDN'),
                    'search' => Configure::read('Ldap.search'),
                    'errors' => Configure::read('Ldap.errors'),
                    'logErrors' => Configure::read('Ldap.logErrors'),
                    'options' => Configure::read('Ldap.options'),
                    'flash' => [
                        'key' => 'ldap',
                        'element' => 'Flash/error',
                    ]
                ]
            ]
        ]);
    }

Setting the Base LDAP settings

config/app.php:, (*6)

    /**
     * LDAP Configuration.
     *
     * Contains an array of settings to use for the LDAP configuration.
     *
     * ## Options
     *
     * - `domain` - The domain name to match against or auto complete so user isn't
     *    required to enter full email address
     * - `host` - The domain controller hostname. This can be a closure or a string.
     *    The closure allows you to modify the rules in the configuration without the
     *    need to modify the LDAP plugin. One host (string) should be returned when
     *    using closure.
     * - `baseDN` - The base DN for directory - Closure must be used here, the plugin
     *    is expecting a closure object to be set.
     * - `bindDN` - The bind DN for directory - Closure must be used here, the plugin
     *    is expecting a closure object to be set.
     * - `search` - The attribute to search against. Usually 'UserPrincipalName'
     * - `port` - The port to use. Default is 389 and is not required.
     * - `errors` - Array of errors where key is the error and the value is the error
     *    message. Set in session to Flash.ldap for flashing
     * - `logErrors` - Should the errors be logged
     * - `options` - Array of options to set using ldap_set_option
     *
     * @link http://php.net/manual/en/function.ldap-search.php - for more info on ldap search
     */
    'Ldap' => [
        'domain' => 'example.com',
        'host' => function() {
            $hosts = ['192.168.1.13', '127.0.0.1'];
            shuffle($hosts);
            return $hosts[0];
        },
        //'host' => '127.0.0.1',
        'port' => 389,
        'search' => 'UserPrincipalName',
        'baseDN' => function($username, $domain) {
            if (strpos($username, $domain) !== false) {
                $baseDN = 'OU=example,DC=domain,DC=local';
            } else {
                $baseDN = 'CN=Users,DC=domain,DC=local';
            }
            return $baseDN;
        },
        'bindDN' => function($username, $domain) {
            $bindDN = "CN=".$username.", OU=example";
            return $bindDN;
        },
        'errors' => [
            'data 773' => 'Some error for Flash',
            'data 532' => 'Some error for Flash',
        ],
        'logErrors' => true,
        'options' => [
            LDAP_OPT_NETWORK_TIMEOUT => 5,
            LDAP_OPT_PROTOCOL_VERSION => 3
        ]
    ]

Credits

This work is based on the code by QueenCityCodeFactory., (*7)

The Versions

08/06 2018

dev-master

9999999-dev http://github.com/jeffersonsimaogoncalves/cakephp-ldap

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

cakephp ldap authenticate

08/06 2018

3.6.2

3.6.2.0 http://github.com/jeffersonsimaogoncalves/cakephp-ldap

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

cakephp ldap authenticate

08/06 2018

3.6.1

3.6.1.0 http://github.com/jeffersonsimaogoncalves/cakephp-ldap

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

cakephp ldap authenticate

30/05 2018

3.6.0

3.6.0.0 http://github.com/jeffersonsimaogoncalves/cakephp-ldap

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

cakephp ldap authenticate

03/10 2017

3.2.6

3.2.6.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

04/10 2016

3.2.5

3.2.5.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

04/10 2016

3.2.4

3.2.4.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

21/07 2016

3.2.3

3.2.3.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

06/07 2016

3.2.2

3.2.2.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

28/03 2016

3.2.1

3.2.1.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

26/03 2016

3.2

3.2.0.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

05/01 2016

1.1

1.1.0.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate

06/11 2015

1.0

1.0.0.0 http://github.com/QueenCityCodeFactory/LDAP

LDAP plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp ldap authenticate