1.0.9 2019-08-23 06:00 UTC

This package is auto-updated.

Last update: 2024-09-23 17:05:38 UTC


README

ldap.

Installing

$ composer require shencongcong/ldap ~1.0

配置

Laravel 应用

  1. config/app.php 注册 ServiceProvider
'providers' => [
    // ...
    Shencongcong\Ldap\ServiceProvider::class,
],
  1. 创建配置文件:
php artisan vendor:publish --provider="Shencongcong\Ldap\ServiceProvider"
  1. 修改应用根目录下的 config/ldap.php 中对应的参数即可

说明

Usage

use Shencongcong\Ldap\Ldap;

$config = [
    'default' => [
        // 网关调用策略,默认:顺序调用
        'strategy' => \Shencongcong\Ldap\Strategies\OrderStrategy::class,
        // 默认可用的发送网关
        'gateways' => [
            'home','idc'
        ],
    ],
    'gateways' => [
        'home' => [
            'url' => 'LDAP://10.0.0.110/',
        ],
        'idc' => [
            'url' => 'LDAP://10.0.0.150/',
        ],
    ],
];

$ldap = new Ldap($config);

1. 验证账号密码
$username = 'xxxx';
$password = 'xxxx';
$gateways = ['home','idc'];
$res = $ldap->ldapCheck($username,$password,$gateways);

2. 根据用户名模糊查找用户
$username = 'xxxx';
$gateways = ['home','idc'];
$res = $ldap->userSearch($username,$gateways);

3. 根据邮箱模糊查找用户
$email = 'xxxx';
$gateways = ['home','idc'];
$res = $ldap->emailSearch($email,$gateways);

License

MIT