utbvirtual/openldapsavio

适用于Laravel 5和UTB认证的OpenLDAP认证驱动程序。

1.1.1 2016-05-12 12:59 UTC

This package is not auto-updated.

Last update: 2024-09-20 19:26:05 UTC


README

Laravel 5的认证驱动程序。

##安装 将其添加到 composer.json 并使用 composer install / composer update 安装。

{
  require: {
    "utbvirtual/openldapsavio": "dev-master"
  }
}

##添加到Laravel 打开您的文件 config/app.php 并在 providers 数组中添加服务提供者。

utbvirtual\openldapsavio\LdapAuthServiceProvider::class

更新您的文件 config/auth.php 以使用 ldap 驱动程序。

'driver' => 'ldap'

##手动配置 手动创建文件 config/ldap.php 并添加以下内容

<?php

return [
    'host'      => 'ldaps://example.com',
    'rdn'       => 'ou=System,dc=example,dc=com', // rdn used by the user configured below, optional
    'version'   => '3', // LDAP protocol version (2 or 3)
    
    'basedn'    => 'ou=People,dc=example,dc=com', // basedn for users
    'login_attribute' => 'uid', // login attributes for users
];

?>

在文件 App\User 中创建函数 createOrUpdateUser(),该函数接收凭据和LDAP的所有信息,检查用户是否存在,如果不存在,则从这些数据创建用户。

示例

public function createOrUpdateUser($credentials){
        $user = User::where('codigo', '=', $credentials['username'])->first();
        if (!$user) {
            $userdata = ['codigo' => $credentials['username'],
            'name' => $credentials['cn'], 'email' => $credentials['mail']];
            $user = User::create($userdata);
        }
        return $user;
}

##关于 基于包 Kuan-Chien Chung(kcchung) l5-openldap-auth。由 Santiago Mendoza 编辑