nohnaimer/yii2-ldaprecord 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nohnaimer/yii2-ldaprecord

最新稳定版本:0.3.1

Composer 安装命令:

composer require nohnaimer/yii2-ldaprecord

包简介

Yii2 extension for library LdapRecord

README 文档

README

Latest Stable Version License Total Downloads

Documentation for LdapRecord

Installation

The preferred way to install this extension is through composer.

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

or add

"nohnaimer/yii2-ldaprecord": "*"

to the require section of your composer.json file.

Configuration

'components' => [
...
'ldap' => [
            'class' => nohnaimer\ldaprecord\LdapRecord::class,
            'providers' => [
                'ad' => [
                    'class' => nohnaimer\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
                    ],
                ],
            ],
        ],
...
],

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');

统计信息

  • 总下载量: 162
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2021-05-07