A framework for
Rapid LDAP Integration

LdapRecord is a framework that helps you quickly integrate LDAP into your PHP applications.

Declarative
LDAP Models.

Each LDAP object type has its own model. If you've used Laravel's Eloquent, you'll feel right at home.

use LdapRecord\Models\Model;

class User extends Model
{
    protected $objectClasses = [
        'top',
        'person',
        'organizationalperson',
        'user',
    ];
}
$user = User::create([
    'company'        => 'LdapRecord',
    'title'          => 'Web Developer',
    'password'       => 'P@ssw0rd',
    'samaccountname' => 'sbauman',
    'mail'           => 'sbauman@acme.org',
    'givenname'      => 'Steve',
    'sn'             => 'Bauman',
]);
User::in('ou=office,dc=local,dc=com')
    ->whereEnabled()
    ->whereMemberOf('cn=managers,ou=groups,dc=local,dc=com')
    ->whereNotContains('company', 'acme')
    ->get()
    ->each(function ($user) {
        $user->company = 'Acme Organization';

        $user->save();
    });

Fluently query
Like a boss.

LdapRecord's filter builder provides a clean, chainable API, that's easy to read and write.

Batteries
Come included.

Events, caching, logging, testing tools, relationships, accessors, mutators, and more.

$dispatcher = Container::getEventDispatcher();

$dispatcher->listen(Saved::class, function (Saved $event) {
    Mail::send(
        new LdapObjectModified($event->getModel())
    );
});
$connection = Container::getDefaultConnection();

$connection->setCache($myAppCache);

$until = new \DateTime('tomorrow');

$users = User::cache($until)->get();
$user = User::find('cn=John Doe,dc=local,dc=com');

$groups = $user->groups()->get();

foreach ($groups as $group) {
    echo $group->getName() . PHP_EOL;
}

Ready to get started?

Show me the way