PHPackages                             mindcontact-dev/yii2-ldap-auth - 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. mindcontact-dev/yii2-ldap-auth

ActiveYii2-extension[Authentication &amp; Authorization](/categories/authentication)

mindcontact-dev/yii2-ldap-auth
==============================

Simple library to handle auth over LDAP in Yii 2 applications. Forked from stmswitcher/yii2-ldap-auth

0.1(6y ago)06MITPHPPHP &gt;= 7.3

Since Jul 1Pushed 4y agoCompare

[ Source](https://github.com/mindcontact-dev/yii2-ldap-auth)[ Packagist](https://packagist.org/packages/mindcontact-dev/yii2-ldap-auth)[ RSS](/packages/mindcontact-dev-yii2-ldap-auth/feed)WikiDiscussions master Synced today

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

Yii2 LDAP Auth
==============

[](#yii2-ldap-auth)

Simple extension to handle auth over LDAP in Yii 2 applications.

**This extension intended for applications that rely *only* on LDAP authentication and does not support access tokens.**

Installation
============

[](#installation)

```
composer require "MindContact/yii2-ldap-auth:master"
```

Example of configuration and a use case
=======================================

[](#example-of-configuration-and-a-use-case)

Considering [yii2-app-basic](https://github.com/yiisoft/yii2-app-basic):

### Configure the component in your configuration file and change user identity class

[](#configure-the-component-in-your-configuration-file-and-change-user-identity-class)

```
'components' => [
    ...
    'ldapAuth' => [
        'class' => '\MindContact\Yii2LdapAuth\LdapAuth',
        'host' => 'ldap-server',
        'baseDn' => 'dc=shihadeh,dc=intern',
        'searchUserName' => 'cn=admin,dc=shihadeh,dc=intern',
        'searchUserPassword' => 'test1234',

        // optional parameters and their default values
        'ldapVersion' => 3,             // LDAP version
        'protocol' => 'ldap://',       // Protocol to use
        'followReferrals' => false,     // If connector should follow referrals
        'port' => 389,                  // Port to connect to
        'loginAttribute' => 'cn',      // Identifying user attribute to look up for
        'ldapObjectClass' => 'inetOrgPerson',  // Class of user objects to look up for
        'timeout' => 10,                // Operation timeout, seconds
        'connectTimeout' => 5,          // Connect timeout, seconds
        'roleMappings' => [
            'cn=Admins,ou=Groups,dc=shihadeh,dc=intern' => 'admin',
            'cn=Maintaners,ou=Groups,dc=shihadeh,dc=intern' => 'operator',
        ],
        'isEnabled' => false,
        'demoUser' => [
            'Id' => 'demo.user',
            'Username' => 'Demo User',
            'Email' => 'demo.user@demo.com',
            'Dn' => 'cn=demo_user,dc=shihadeh,dc=intern',
            'Roles' => ['admin']
        ]
    ],
    ...

    'user' => [
        'identityClass' => '\MindContact\Yii2LdapAuth\Model\LdapUser',
        'enableSession' => true,
        'enableAutoLogin' => true,
    ],
    ...
]
```

### Update methods in LoginForm class

[](#update-methods-in-loginform-class)

```
use MindContact\Yii2LdapAuth\Model\LdapUser;

...

public function validatePassword($attribute, $params)
{
    if (!$this->hasErrors()) {
        $user = LdapUser::findIdentity($this->username);

        if (!$user || !Yii::$app->ldapAuth->authenticate($user->getDn(), $this->password) {
            $this->addError($attribute, 'Incorrect username or password.');
        }
    }
}

...

public function login()
{
    if ($this->validate()) {
        return Yii::$app->user->login(
            LdapUser::findIdentity($this->username),
            $this->rememberMe
                ? 3600*24*30 : 0
        );
    }
    return false;
}
```

### Verify that user belongs to LDAP group

[](#verify-that-user-belongs-to-ldap-group)

If you need also need to check if user is a member of certain LDAP group, use one more parameter for the `authenticate` function:

```
Yii::$app->ldapAuth->authenticate($user->getDn(), $this->password, 'cn=auth-user-group')
```

Now you can login with LDAP credentials to your application.

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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

2239d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f86291b1355bf98df17af7084823d47bc87446e435de0b16aaf84bd55adfa6e?d=identicon)[MindContact](/maintainers/MindContact)

---

Top Contributors

[![MindContact](https://avatars.githubusercontent.com/u/5485442?v=4)](https://github.com/MindContact "MindContact (10 commits)")[![stmswitcher](https://avatars.githubusercontent.com/u/10289021?v=4)](https://github.com/stmswitcher "stmswitcher (2 commits)")

---

Tags

authyii2extensionldap

### Embed Badge

![Health badge](/badges/mindcontact-dev-yii2-ldap-auth/health.svg)

```
[![Health](https://phpackages.com/badges/mindcontact-dev-yii2-ldap-auth/health.svg)](https://phpackages.com/packages/mindcontact-dev-yii2-ldap-auth)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13926.0k66](/packages/skeeks-cms)[chrmorandi/yii2-ldap

Ldap

1454.7k](/packages/chrmorandi-yii2-ldap)[kakadu-dev/yii2-jwt-auth

Extension provide JWT auth for Yii2

105.8k](/packages/kakadu-dev-yii2-jwt-auth)

PHPackages © 2026

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