chrmorandi/yii2-adldap2

This package is abandoned and no longer maintained. No replacement package was suggested.

Yii2 wrapper for PHP LDAP Library with Active Directory Manipulation

v0.3.0 2016-04-03 20:12 UTC

This package is not auto-updated.

Last update: 2019-02-20 18:54:23 UTC


README

Yii2 wrapper for PHP LDAP Library with Active Directory Manipulation. It provides ability to use original Adldap class as Yii2 component.

Installation

The preferred way to install this extension is through Composer.

Either run

composer require chrmorandi/yii2-adldap "*"

or add

"chrmorandi/yii2-adldap": "*"

to the require section of your composer.json

Configuration

Add this code in your components section of the application configuration (eg. config/main.php):

'components' => [
    ...
    'adldap' => [
        'class' => 'chrmorandi\adldap2\Adldap',
        'options' => [
            // Mandatory Configuration Options
            'domain_controllers' => [
                '192.168.0.1',
                '192.168.0.2'
            ],
            'base_dn'               => 'dc=ifnmg,dc=edu,dc=br',
            'admin_username'        => 'admin',
            'admin_password'        => 'password',
            // Optional Configuration Options
            'account_prefix'        => 'IFNMG-',
            'account_suffix'        => '@ifnmg.edu.br',
            'admin_account_suffix'  => '@ifnmg.edu.br',
            'port'                  => 389,
            'follow_referrals'      => false,
            'use_ssl'               => false,
            'use_tls'               => false,
        ],
        // Optional Name For Provider Instance
        'providerName' => 'default'
    ],
    ...
]

All options and methods are the same as in original class. Take a look at documentation if you need more info.

Examples

Authentication with username and password:

try {
    if (\yii::$app->adldap->auth()->attempt($username, $password)) {
        // Credentials were correct.
    } else {
        // Credentials were incorrect.
    }
} catch (\Adldap\Exceptions\Auth\UsernameRequiredException $e) {
    // The user didn't supply a username.
} catch (\Adldap\Exceptions\Auth\PasswordRequiredException $e) {
    // The user didn't supply a password.
}

More examples