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

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

kcone87/yii2-ldap-auth
======================

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

29PHP

Since Jul 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kcone87/yii2-ldap-auth)[ Packagist](https://packagist.org/packages/kcone87/yii2-ldap-auth)[ RSS](/packages/kcone87-yii2-ldap-auth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)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)

```
php composer.phar require --prefer-dist kcone87/yii2-ldap-auth "*"
```

or add

```
"kcone87/yii2-ldap-auth": "*"

```

to the require section of your composer.json file.

To always use the latest version from Github, in your composer.json, add this repository to the repositories section.

```
{
    ...
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/kcone87/yii2-ldap-auth"
        }
    ],
}

```

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' => '\kcone87\Yii2LdapAuth\LdapAuth',
        'host' => 'your-ldap-hostname',
        'baseDn' => 'dc=work,dc=group',
        'searchUserName' => '',
        'searchUserPassword' => '',
        'userDomain' => '',//user domain
        // optional parameters and their default values
        'ldapVersion' => 3,             // LDAP version
        'protocol' => ['ldap://', 'ldaps://'],       // Protocol to use
        'followReferrals' => false,     // If connector should follow referrals
        'port' => 636,                  // Port to connect to
        'loginAttribute' => 'uid',      // Identifying user attribute to look up for
        'ldapObjectClass' => 'person',  // Class of user objects to look up for
        'timeout' => 10,                // Operation timeout, seconds
        'connectTimeout' => 5,          // Connect timeout, seconds
    ],
    ...

    'user' => [
        'identityClass' => '\kcone87\Yii2LdapAuth\Model\LdapUser',
    ],
    ...
]
```

### Update methods in LoginForm class

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

```
use kcone87\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.');
        }
    }

    //if user is a member of a group
    //Yii::$app->ldapAuth->authenticate($this->username, $user->getDn(), $this->password, $userGroup)//check user
}

...

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

Now you can login with LDAP credentials to your application.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bd8766f7c105eacd8f02829c6693021c8a045a52a274dae5cf1d1118ae48a01?d=identicon)[willien](/maintainers/willien)

---

Top Contributors

[![kcone87](https://avatars.githubusercontent.com/u/12767553?v=4)](https://github.com/kcone87 "kcone87 (13 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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