luitd/lu-ldap-authorization

LDAP Authorization Library for University of Latvia

2.1.0 2022-07-25 13:45 UTC

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

TypeGetterDescription
intgetUid()User identification
UsernamegetUsername()Username
EmailgetEmail()User e-mail address
stringgetPhone()User phone number
stringgetFirstName()User given name
stringgetLastName()User surname
stringgetFullName()User full name
stringgetDisplayName()User display name
DateTimegetPasswordChangedAt()Timestamp of last password change
CollectiongetGroups()Assigned user access groups
CollectiongetLDAPGroups()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 FileAssertions
Unit/LDAPUserTest.php23
Type/EmailTest.php10
Type/UsernameTest.php10
Functional/LDAPTest.php3

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>