luitd / lu-ldap-authorization
LDAP Authorization Library for University of Latvia
Requires (Dev)
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2024-12-10 01:07:35 UTC
README
Version 2.1
Requirements
PHP 7.4
- PHP LDAP Extension
Install via Composer
composer req luitd/lu-ldap-authorization
Usage
$ldapAuth = new LDAP($ldapServer, $ldapDc);
$user = $ldapAuth->authorize($username, $password);
Variable $user
will contain null
on failed authorization and LDAPUser
object on successfully authorization!
LDAPUser Object
Type | Getter | Description |
---|---|---|
int | getUid() | User identification |
Username | getUsername() | Username |
getEmail() | User e-mail address | |
string | getPhone() | User phone number |
string | getFirstName() | User given name |
string | getLastName() | User surname |
string | getFullName() | User full name |
string | getDisplayName() | User display name |
DateTime | getPasswordChangedAt() | Timestamp of last password change |
Collection | getGroups() | Assigned user access groups |
Collection | getLDAPGroups() | Assigned user access LDAP groups |
Important changes from 1.x
1) Username
and Email
has been remade into Type classes, use toString()
to get plain values!
2) Groups
and LDAPGroups
have been remade into Collections, use all()
to get content!
3) cn
has been renamed to fullName
to better show its true purpose!
4) givenname
has been renamed to firstName
to better show its true purpose!
5) sn
has been renamed to lastName
to better show its true purpose!
6) LDAPUser no longer contains dc
return value!
All variables set to camelCase standard.
Testing
./vendor/bin/phpunit ./vendor/luitd/lu-ldap-authorization/tests (or /<test-file>)
Test File | Assertions |
---|---|
Unit/LDAPUserTest.php | 23 |
Type/EmailTest.php | 10 |
Type/UsernameTest.php | 10 |
Functional/LDAPTest.php | 3 |
LDAPTest requires LDAP connection data.
Specify your server and user details with
LDAPTest.php ldapServer=<your-server> ldapDC=<your-dc> ldapUser=<test-user> ldapPass=<test-pass>