surda / adldap2-nette
Adldap2 integration into Nette Framework
v2.0.2
2022-12-16 09:04 UTC
Requires
- php: >=8.0
- ext-ldap: *
- adldap2/adldap2: ^10.0
- nette/di: ^3.0
Requires (Dev)
- nette/tester: ^2.0
- ninjify/nunjuck: ^0.3
- phpstan/phpstan: ^1.4
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-nette: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
Conflicts
- nette/di: <2.4
README
Installation
The recommended way to is via Composer:
composer require surda/adldap2-nette
After that you have to register extension in config.neon:
extensions: adldap: Surda\Adldap\DI\AdldapExtension adldap.credentialsFactory: Surda\Adldap\DI\LdapCredentialsExtension
Minimal configuration
adldap: hosts: { 'corp-dc1.corp.acme.org', 'corp-dc2.corp.acme.org' } base_dn: 'dc=corp,dc=acme,dc=org' username: 'admin' password: 'password'
List of all configuration options:
adldap: # Mandatory configuration options hosts: { 'corp-dc1.corp.acme.org', 'corp-dc2.corp.acme.org' } base_dn: 'dc=corp,dc=acme,dc=org' username: 'admin' password: 'password' # Optional configuration options schema: \Adldap\Schemas\ActiveDirectory account_prefix: 'ACME-' account_suffix: '@@acme.org' port: 389 follow_referrals: FALSE use_ssl: false use_tls: false version: 3 timeout: 5 adldap.credentialsFactory: accountPrefix: '' accountSuffix: '@@ad.domain.com'
Usage
use Adldap\Adldap; use Adldap\Auth\BindException; use Adldap\Auth\PasswordRequiredException; use Adldap\Auth\UsernameRequiredException; class Foo { public function __construct(private Adldap $adldap) { } public function auth(): bool { $provider = $this->adldap->connect(); try { return $provider->auth()->attempt('username', 'password'); } catch (BindException $e) { } catch (PasswordRequiredException $e) { } catch (UsernameRequiredException $e) { } } }
More in the Adldap2 documentation.