ohffs/simple-laravel-ldap
最新稳定版本:2.0.3
Composer 安装命令:
composer require ohffs/simple-laravel-ldap
包简介
Basic LDAP auser auth/lookup
README 文档
README
WIP
Simple LDAP package for Laravel
This is a very, very simple and very specific LDAP package. It's really just a wrapper of code I usually copy from project to project to do LDAP lookups of our local LDAP server, so it's usefulness outside of that is probably quite limited. But it might be useful as a basis for your own setup.
Installation
composer require ohffs/simple-laravel-ldap
I'm assuming this is for Laravel 5.5+ so it should auto-discover the service providers. You can then publish the config file :
php artisan vendor:publish
And pick the 'Ohffs\Ldap\LdapServiceProvider' option which will create a config/ldap.php file. This
just looks for two env variables which you should set - LDAP_SERVER and LDAP_OU eg,
LDAP_SERVER=ldap.your-domain.com
LDAP_OU=Staff
Usage
You can use the facade to access the main methods :
if (\Ldap::authenticate('username', 'password')) {
// whatever
}
$user = \Ldap::findUser('jenny123');
dump($user);
/*
Ohffs\Ldap\LdapUser {#739
#username: "jenny123"
#email: "Jenny@example.com"
#surname: "Smith"
#forenames: "Jenny"
#phone: "012345678"
}
*/
print $user['email'];
// 'Jenny@example.com'
print $user->email;
// 'Jenny@example.com'
print $user->toArray();
/*
[
"username" => "jenny123",
"email" => "Jenny@example.com",
"surname" => "Smith",
"forenames" => "Jenny",
"phone" => "012345678",
]
*/
Or if you want to use the container/DI just typehint on 'Ohffs\Ldap\LdapService':
use Ohffs\Ldap\LdapService;
public function __construct(LdapService $ldap)
{
$this->ldap = $ldap;
}
public function something()
{
if ($this->ldap->authenticate('username', 'password')) {
// ...
}
}
统计信息
- 总下载量: 4.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-06