PHPackages                             rubyan/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. rubyan/ldap

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

rubyan/ldap
===========

LDAP plugin for CakePHP 3.x

3.6(7y ago)01.2kMITPHPPHP &gt;=5.4.16

Since Nov 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Rubyan/LDAP)[ Packagist](https://packagist.org/packages/rubyan/ldap)[ Docs](http://github.com/Rubyan/LDAP)[ RSS](/packages/rubyan-ldap/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

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

[](#ldap-authenticate-plugin)

LDAP Authenticate Plugin for CakePHP 3.x and AuthComponent.

based on the excellent work of queencitycodefactory/ldap

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

[](#requirements)

- CakePHP 3.0
- php5-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 rubyan/ldap

```

You can also add `"rubyan/ldap" : "dev-master"` to `require` section in your application's `composer.json`.

Enable ldap in php.ini:

```
extension=php_ldap.dll

```

Usage
-----

[](#usage)

In your app's `config/bootstrap.php` add: `Plugin::load('Rubyan/LDAP');`

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' => [
                'Rubyan/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'),
                    'search' => Configure::read('Ldap.search'),
                    'errors' => Configure::read('Ldap.errors'),
                    '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. You can find your ldap servers with the following command:
     *      host -t srv _ldap._tcp.YOURDOMAIN.LOCAL
     * - `port` - The port to use. Default is 389 and is not required.
     * - `search` - The attribute to search against. Usually 'UserPrincipalName'
     * - `baseDN` - The base DN for directory - Closure must be used here, the plugin
     *    is expecting a closure object to be set.
     * - `attributes` - An array of the required attributes, e.g. ["mail", "sn", "cn"].
     *    Note that the "dn" is always returned irrespective of which attributes types are
     *    requested.
     * - `errors` - Array of errors where key is the error and the value is the error
     *    message. Set in session to Flash.ldap for flashing
     *
     * @link http://php.net/manual/en/function.ldap-search.php - for more info on ldap search
     */
    'Ldap' => [
        'domain' => 'domain.local',
        'host' => function() {
            $hosts = [
                'host1.domain.local',
                'host2.domain.local'
            ];
            shuffle($hosts);
            return $hosts[0];
        },
        'port' => 389,
        'search' => function($username, $domain) {
            if (strpos($username, $domain) !== false) {
                // remove the @domain from username
                $username = str_replace('@' . $domain, '', $username);
            }
            $search = '(&(objectCategory=person)(samaccountname=' . $username. '))';
            return $search;
        },
        'baseDN' => function($username, $domain) {
            if (strpos($username, $domain) !== false) {
                $baseDN = 'OU=Domain,DC=domain,DC=local';
            } else {
                $baseDN = 'CN=Users,DC=domain,DC=local';
            }
            return $baseDN;
        },
        'attributes' => ['samaccountname','mail', 'displayname'],
        'errors' => [
            'data 773' => 'Some error for Flash',
            'data 532' => 'Some error for Flash',
        ]
    ],
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 53.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

Every ~189 days

Recently: every ~251 days

Total

7

Last Release

2751d ago

Major Versions

1.5 → 3.62018-12-18

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/87746779?v=4)[rubyan](/maintainers/rubyan)[@rubyan](https://github.com/rubyan)

---

Top Contributors

[![darensipes](https://avatars.githubusercontent.com/u/840593?v=4)](https://github.com/darensipes "darensipes (14 commits)")[![johanvanderkuijl](https://avatars.githubusercontent.com/u/1000115?v=4)](https://github.com/johanvanderkuijl "johanvanderkuijl (7 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)")

---

Tags

cakephpldapauthenticate

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[cakedc/users

Users Plugin for CakePHP

523918.4k18](/packages/cakedc-users)[dereuromark/cakephp-tinyauth

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

131237.3k13](/packages/dereuromark-cakephp-tinyauth)[admad/cakephp-jwt-auth

CakePHP plugin for authenticating using JSON Web Tokens

160717.9k8](/packages/admad-cakephp-jwt-auth)[queencitycodefactory/ldap

LDAP plugin for CakePHP 3.x

139.9k1](/packages/queencitycodefactory-ldap)[dereuromark/cakephp-setup

A CakePHP plugin containing lots of useful management tools

35184.7k2](/packages/dereuromark-cakephp-setup)[andrej-griniuk/cakephp-two-factor-auth

CakePHP auth component and provider fot two-factor authentication

38107.7k](/packages/andrej-griniuk-cakephp-two-factor-auth)

PHPackages © 2026

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