PHPackages                             jeffersonsimaogoncalves/cakephp-ldap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. jeffersonsimaogoncalves/cakephp-ldap

ActiveCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

jeffersonsimaogoncalves/cakephp-ldap
====================================

LDAP plugin for CakePHP 3.x

3.6.2(8y ago)220MITPHPPHP &gt;=7.0

Since Jun 8Pushed 8mo agoCompare

[ Source](https://github.com/jeffersongoncalves/cakephp-ldap)[ Packagist](https://packagist.org/packages/jeffersonsimaogoncalves/cakephp-ldap)[ Docs](http://github.com/jeffersonsimaogoncalves/cakephp-ldap)[ RSS](/packages/jeffersonsimaogoncalves-cakephp-ldap/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

LDAP Authenticate plugin
========================

[](#ldap-authenticate-plugin)

LDAP Authenticate Plugin for CakePHP 3.x and AuthComponent.

Requirements
------------

[](#requirements)

- CakePHP 3.6
- php7.0-ldap module

Installation
------------

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require jeffersonsimaogoncalves/cakephp-ldap

```

Usage
-----

[](#usage)

Include the CakeSoap library files:

```
    use Ldap\Auth\LdapAuthenticate;
```

Configuration:
--------------

[](#configuration)

Setup the authentication class settings

### AppController Setup:

[](#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

[](#setting-the-base-ldap-settings)

config/app.php:

```
    /**
     * 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
-------

[](#credits)

This work is based on the [code by QueenCityCodeFactory](https://github.com/QueenCityCodeFactory/LDAP).

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance42

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2949d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/411493?v=4)[Jefferson Gonçalves](/maintainers/jeffersongoncalves)[@jeffersongoncalves](https://github.com/jeffersongoncalves)

---

Top Contributors

[![darensipes](https://avatars.githubusercontent.com/u/840593?v=4)](https://github.com/darensipes "darensipes (22 commits)")[![jeffersongoncalves](https://avatars.githubusercontent.com/u/411493?v=4)](https://github.com/jeffersongoncalves "jeffersongoncalves (4 commits)")[![joshrhykerd](https://avatars.githubusercontent.com/u/227919?v=4)](https://github.com/joshrhykerd "joshrhykerd (3 commits)")[![jrble819](https://avatars.githubusercontent.com/u/755205?v=4)](https://github.com/jrble819 "jrble819 (2 commits)")[![watermark](https://avatars.githubusercontent.com/u/1056975?v=4)](https://github.com/watermark "watermark (1 commits)")

---

Tags

cakephpldapauthenticate

### Embed Badge

![Health badge](/badges/jeffersonsimaogoncalves-cakephp-ldap/health.svg)

```
[![Health](https://phpackages.com/badges/jeffersonsimaogoncalves-cakephp-ldap/health.svg)](https://phpackages.com/packages/jeffersonsimaogoncalves-cakephp-ldap)
```

###  Alternatives

[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

131240.2k13](/packages/dereuromark-cakephp-tinyauth)[cakedc/users

Users Plugin for CakePHP

525928.0k20](/packages/cakedc-users)[cakephp/bake

Bake plugin for CakePHP

11212.0M202](/packages/cakephp-bake)[admad/cakephp-jwt-auth

CakePHP plugin for authenticating using JSON Web Tokens

163762.9k8](/packages/admad-cakephp-jwt-auth)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308954.9k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M44](/packages/dereuromark-cakephp-ide-helper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
