mathermann/php-ldap-client

1.0.0 2023-08-24 21:50 UTC

This package is auto-updated.

Last update: 2024-10-25 00:41:52 UTC


README

Latest version on Packagist Total downloads Licence PHP version
Easily authenticate users and deal with LDAP server in PHP

Usage

<?php

require_once 'vendor/autoload.php';

use MatHermann\Ldap\Exception\LdapException;
use MatHermann\Ldap\LdapClient;

try {
    $host = '127.0.0.1';
    $port = 389;
    $dn = 'DC=yourDomain,DC=com';
    $OU = 'yourOrganizationalUnit';

    $username = 'yourUsername';
    $password = 'yourPassword';

    $client = new LdapClient($host, $port, $dn);

    $user = $client->signInUser($username, $password, "OU=$OU");

    var_dump($user); // Access user properties with $user->get('property')

} catch (LdapException $exception) {
    var_dump($exception); // Handle LDAP exceptions
}