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

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

websvc/yii2-ldap
================

Ldap

1.0.5(7y ago)122MITPHPPHP &gt;=5.6

Since Dec 31Pushed 7y ago1 watchersCompare

[ Source](https://github.com/websvcPT/yii2-ldap)[ Packagist](https://packagist.org/packages/websvc/yii2-ldap)[ RSS](/packages/websvc-yii2-ldap/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

Ldap database and ActiveRecord for Yii 2
========================================

[](#ldap-database-and-activerecord-for-yii-2)

This extension provides the LDAP integration for the Yii framework 2.0. It includes basic querying/search support and also implements the ActiveRecord pattern that allows you to store active records in Active Directory or OpenLDAP.

Disclaimer
----------

[](#disclaimer)

This is a fork of

Only to have some maintainability over the code and have a production release of the composer package

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bad30632fc248bfc496dcdecebdc4c4f167a5ea2a25e1c1eb6023a07fff50c66/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6368726d6f72616e64692f796969322d6c6461702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/chrmorandi/yii2-ldap/?branch=master)

Changelog
---------

[](#changelog)

[See Changelog ](CHANGELOG.md)

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

[](#requirements)

To use yii2-ldap, your sever must support:

PHP LDAP Extension

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist websvc/yii2-ldap

```

or add

```
"websvc/yii2-ldap": "*"
```

to the require section of your composer.json.

Configuration
-------------

[](#configuration)

```
return [
    //....
    'components' => [
        'ldap' => [
            'class' => 'websvc\ldap\Connection',
            // Mandatory Configuration Options
            'dc' => [
                '192.168.1.1',
                'ad.com'
            ],
            'baseDn'          => 'dc=ad,dc=com',
            'username'        => 'administrator@ad.com',
            'password'        => 'password',
            // Optional Configuration Options
            'port'            => 389,
            'followReferrals' => false,
            'useTLS'          => true,
            // Change pageSize (e.g. to 1000) if you are getting the following message
            // with large result sets:
            // ldap_search(): Partial search results returned: Sizelimit exceeded
            'pageSize'        => -1,
            // Change the attribute to use for login
            'loginAttribute'        => 'uid',
            // for check if user has access to application
            'authAccess'      => [
                'cn' => 'cn=restricted,ou=Groups',  // Cn name, will be concatenated with baseDn
                'objectClass' => 'posixGroup',      // object class to search
                'attributeMatch' => 'memberUid',    // attribute to match user
            ]
        ],
    ]
];
```

### Authenticate User

[](#authenticate-user)

To authenticate users using your AD server, call the `Yii::$app->ldap->auth()`method on your provider:

```
try {
    if (Yii::$app->ldap->auth($this->username, $password)) {
        // Credentials were correct.
    } else {
        // Credentials were incorrect.
    }
    } catch (Exception $e) {
        // error
    }
}
```

### Authenticate User, check access and retrieve user data

[](#authenticate-user-check-access-and-retrieve-user-data)

To authenticate users using your AD server, call the `Yii::$app->ldap->auth()`method on your provider:

```
try {
    $ldap = Yii::$app->ldap;

    if($ldap->auth($this->username, $this->password)) { //Yii loginform username/password

        $user_data = $ldap->checkAccessReturnUserdata();

        if( !empty($user_data)){

            if ($this->_user === null) {
                // Do your magic
                echo '';
                print_r($user_data);
                echo '';
            }
        }
    } else {
        // Credentials were incorrect.
        // Will not return anything
    }
} catch (Exception $e) {
    // error
    // Will not return anything
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.4% 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 ~19 days

Total

5

Last Release

2615d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82408143ff5ef3329c0fff88abd46366a84c7244a43e11dffe1de80f591ba904?d=identicon)[websvc](/maintainers/websvc)

---

Top Contributors

[![chrmmota](https://avatars.githubusercontent.com/u/242634898?v=4)](https://github.com/chrmmota "chrmmota (52 commits)")[![websvcPT](https://avatars.githubusercontent.com/u/1758961?v=4)](https://github.com/websvcPT "websvcPT (6 commits)")[![chrmorandi](https://avatars.githubusercontent.com/u/11622005?v=4)](https://github.com/chrmorandi "chrmorandi (5 commits)")[![factorenergia](https://avatars.githubusercontent.com/u/28297420?v=4)](https://github.com/factorenergia "factorenergia (5 commits)")[![rimas-kudelis](https://avatars.githubusercontent.com/u/2812673?v=4)](https://github.com/rimas-kudelis "rimas-kudelis (1 commits)")

---

Tags

yii2extensionldapactive directoryopenldap

###  Code Quality

TestsCodeception

### Embed Badge

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

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

###  Alternatives

[chrmorandi/yii2-ldap

Ldap

1453.1k](/packages/chrmorandi-yii2-ldap)[edvlerblog/yii2-adldap-module

yii2 Active Directory implementation (wrapper for Adldap2)

51227.3k](/packages/edvlerblog-yii2-adldap-module)[causal/ig_ldap_sso_auth

This extension provides LDAP support for TYPO3 by delegating the authentication of frontend and/or backend users to the centrally-managed directory of your organization. It fully supports OpenLDAP and Active Directory and is capable of connecting securely to the authentication server using either TLS or SSL (ldaps://). In case of use in an intranet environment, this extension is a perfect match since it natively brings Single Sign-On (SSO) capability to TYPO3 without any complex configuration.

33377.4k](/packages/causal-ig-ldap-sso-auth)[ldaptools/ldaptools-bundle

Provides easy LDAP integration for Symfony via LdapTools.

49159.5k](/packages/ldaptools-ldaptools-bundle)[jotaelesalinas/laravel-adminless-ldap-auth

Authenticate users in Laravel against an adminless LDAP server

2105.1k](/packages/jotaelesalinas-laravel-adminless-ldap-auth)

PHPackages © 2026

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