luitd / lu-ldap-authorization
拉脱维亚大学LDAP授权库
2.1.0
2022-07-25 13:45 UTC
Requires (Dev)
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2024-10-01 00:20:38 UTC
README
版本 2.1
需求
PHP 7.4
- PHP LDAP扩展
通过Composer安装
composer req luitd/lu-ldap-authorization
使用方法
$ldapAuth = new LDAP($ldapServer, $ldapDc);
$user = $ldapAuth->authorize($username, $password);
变量$user
在授权失败时将包含null
,在授权成功时将包含LDAPUser
对象!
LDAPUser对象
类型 | 获取器 | 描述 |
---|---|---|
int | getUid() | 用户标识 |
用户名 | getUsername() | 用户名 |
电子邮件 | getEmail() | 用户电子邮件地址 |
string | getPhone() | 用户电话号码 |
string | getFirstName() | 用户名 |
string | getLastName() | 用户姓 |
string | getFullName() | 用户全名 |
string | getDisplayName() | 用户显示名 |
DateTime | getPasswordChangedAt() | 上次密码更改的时间戳 |
集合 | getGroups() | 分配给用户的访问组 |
集合 | getLDAPGroups() | 分配给用户的访问LDAP组 |
1.x版本的重要变更
1) Username
和Email
已重构成类型类,使用toString()
获取纯值!2) Groups
和LDAPGroups
已重构成集合,使用all()
获取内容!3) cn
已重命名为fullName
以更好地展示其真实目的!4) givenname
已重命名为firstName
以更好地展示其真实目的!5) sn
已重命名为lastName
以更好地展示其真实目的!6) LDAPUser不再包含dc
返回值!
所有变量均设置为camelCase标准。
测试
./vendor/bin/phpunit ./vendor/luitd/lu-ldap-authorization/tests (or /<test-file>)
测试文件 | 断言 |
---|---|
Unit/LDAPUserTest.php | 23 |
Type/EmailTest.php | 10 |
Type/UsernameTest.php | 10 |
Functional/LDAPTest.php | 3 |
LDAPTest需要LDAP连接数据。
使用
LDAPTest.php ldapServer=<your-server> ldapDC=<your-dc> ldapUser=<test-user> ldapPass=<test-pass>
指定您的服务器和用户详细信息