kadotafig/yii2-ldaprecord

Yii2 extension for library LdapRecord

Maintainers

👁 kadotafig

Package info

github.com/kadotafig/yii2-ldaprecord

Type:yii2-extension

pkg:composer/kadotafig/yii2-ldaprecord

Statistics

Installs: 11

Dependents: 0

Suggesters: 0

Stars: 0

v0.2.5 2021-08-29 23:59 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause d51802e0be12e5a21c306912fb7ebcee3a513f26

  • Bart Bailey <figkadota.woop@gmail.com>

extensionldapzimbraactive directoryyii2openldapldaprecord

This package is auto-updated.

Last update: 2026-05-29 01:29:15 UTC


README

Documentation for LdapRecord

Documentation for ZimbraLDAP

Installation

The preferred way to install this extension is through composer.

php composer.phar require --prefer-dist kadotafig/yii2-ldaprecord "*"

or add

"kadotafig/yii2-ldaprecord": "*"

to the require section of your composer.json file.

Configuration

'components' => [
...
'ldap' => [
 'class' => kadotafig\ldaprecord\LdapRecord::class,
 'providers' => [
 'ad' => [
 'class' => kadotafig\ldaprecord\LdapRecord::class,
 // Mandatory Configuration Options
 'hosts' => ['192.168.1.1'],
 'base_dn' => 'dc=local,dc=com',
 'username' => 'admin@local.com',
 'password' => 'password',
 
 // Optional Configuration Options
 'port' => 389,
 'follow_referrals' => false,
 'use_ssl' => false,
 'use_tls' => false,
 'version' => 3,
 'timeout' => 5,
 
 // Custom LDAP Options
 'options' => [
 // See: http://php.net/ldap_set_option
 LDAP_OPT_X_TLS_REQUIRE_CERT => LDAP_OPT_X_TLS_HARD
 ],
 ],
 'ldap' => [
 'hosts' => ['192.168.1.2'],
 'base_dn' => 'dc=local,dc=com',
 'username' => 'cn=admin,dc=mts,dc=by',
 'password' => 'password',

 // Optional Configuration Options
 'port' => 389,
 'version' => 3,

 // Custom LDAP Options
 'options' => [
 // See: http://php.net/ldap_set_option
 LDAP_OPT_X_TLS_REQUIRE_CERT => LDAP_OPT_X_TLS_HARD
 ],
 ],
 ],
 'zimbra' => [
 'hosts' => ['192.168.1.2'],
 'base_dn' => 'dc=local,dc=com',
 'username' => 'cn=admin,dc=mts,dc=by',
 'password' => 'password',

 // Optional Configuration Options
 'port' => 389,
 'version' => 3,

 // Custom LDAP Options
 'options' => [
 // See: http://php.net/ldap_set_option
 LDAP_OPT_X_TLS_REQUIRE_CERT => LDAP_OPT_X_TLS_HARD
 ],
 ],
 ],
 ],
...
],

Usage

Simple usage without a user model

Query:

Yii::$app->ldap->initProvider('ad')->query()->where('cn', '=', 'John Doe')->get();

Authentication:

Yii::$app->ldap->initProvider('ad')->auth()->attempt('username', 'password', true);

Simple usage with a model

Model:

class User extends \LdapRecord\Models\ActiveDirectory\User
{
 /**
 * The "booting" method of the model.
 * @throws \LdapRecord\Auth\BindException
 * @throws \LdapRecord\ConnectionException
 */
 protected static function boot()
 {
 Yii::$app->ldap->initProvider('ad');
 }

 protected $connection = 'ad';
}
$user = User::findByGuid('guid');