Authorize, search users, get user groups and other from LDAP

Installs: 533

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 0

Type:yii2-extension

1.0.0 2018-03-07 07:44 UTC

This package is not auto-updated.

Last update: 2020-03-28 22:04:25 UTC


README

Authorize, search users, get user groups and other from LDAP

Yii2 Latest Stable Version Total Downloads Latest Unstable Version License

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist kosoukhov/ldap

or add

"kosoukhov/ldap": "*"

to the require section of your composer.json file.

Application configuration example:

In config/main.php add:

return [
    'components' => [
        'ldap' => [
            'class' => 'kosoukhov\ldap\Connector',
            'useCache' => YII_ENV_DEV ? false : true,
        ],
    ],
    // ...
];

In config/main-local.php add:

return [
    'components' => [
        'ldap' => [
            'host' => 'ldap.example.com',
            'port' => '389',
            'baseDN' => 'OU=...,DC=...,DC=...,DC=net',
            'userDN' => '@....corp.net',
            'groupDN' => '',
            //Input your AD login/pass on dev or sys login/pass on test/prod servers
            'sysUserLogin' => '',
            'sysUserPassword' => '',
        ],
    ],
    // ...
];

Usage example:

if (!Yii::$app->ldap->validateUserCredentials('SAMAccountName', 'password')) {
    throw new ErrorException('Incorrect username or password.');
}
echo Yii::$app->ldap->getUserAttributesBySAMAccountName('SAMAccountName', ['mail', 'sn', 'givenname', 'middlename']);
echo kosoukhov\ldap\widgets\UserImage::widget([
    'login' => Yii::$app->user->identity->username,
    'options' => [
        'class' => 'img-circle',
        'alt' => 'User Image',
    ]
]);