Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Ldaprecord Laravel

Ldaprecord Laravel Laravel Package

directorytree/ldaprecord-laravel

Laravel integration for LdapRecord: authenticate and sync users against Active Directory/LDAP, manage directory connections, and map LDAP attributes to Eloquent models. Includes config, migrations, middleware, and easy-to-use auth/user providers.

View on GitHub
Deep Wiki
Context7

LDAP Authentication & Management for Laravel.

Frequently asked questions about Ldaprecord Laravel
How do I set up multi-domain LDAP authentication in Laravel using this package?
Configure multiple LDAP connections in your `config/ldap.php` file, then define separate `LdapUserProvider` instances for each domain. Use the `LdapGuard` trait to bind each guard to its respective LDAP connection. The package handles routing requests to the correct domain automatically.
What’s the difference between full and incremental sync strategies in LdapImporter?
Full syncs overwrite all records, while incremental syncs (using `lastModified` timestamps) only update changed entries. Incremental syncs are faster for large directories (e.g., 50K+ users) and reduce API load. Use the `--strategy` flag in `ldap:sync` to choose between them.
Can I use this package with Laravel 10 and PHP 8.2+?
Yes, this package fully supports Laravel 10 and PHP 8.2+. Version 4.0.0 dropped PHP 8.1 support, so ensure your environment meets these requirements. Check the [compatibility table](https://github.com/DirectoryTree/LdapRecord-Laravel#requirements) for exact versions.
How do I migrate from raw LDAP filters to the new LdapQueryBuilder?
Replace raw filters like `(&(uid=%s)(objectClass=person))` with the fluent `LdapQueryBuilder`. For example, use `$query->where('uid', $username)->where('objectClass', 'person')`. The package provides a migration guide in the [upgrading docs](https://github.com/DirectoryTree/LdapRecord-Laravel#migrating-from-v3-to-v4).
Does this package support conflict resolution when syncing LDAP and database users?
Yes, it offers three default strategies: LDAP wins (overwrites DB), DB wins (ignores LDAP changes), or custom merge logic. Configure this in your `LdapImporter` settings. For complex scenarios, extend the `ConflictResolver` interface to implement custom rules.
How can I test LDAP interactions in CI/CD without hitting a real directory?
Use the `DirectoryEmulator` to mock LDAP responses, including nested groups and custom schemas. Configure it in your `phpunit.xml` or tests with `$this->app->singleton(DirectoryEmulator::class, fn() => new DirectoryEmulator())`. The emulator supports all CRUD operations and query building.
What’s the best way to handle LDAP downtime in production?
Combine the package’s graceful degradation with Laravel Horizon for circuit breakers. Cache LDAP responses (e.g., with `cache()->remember`) and set a short TTL (e.g., 5 minutes). For critical auth, implement a fallback to database users via `LdapUserProvider::fallback()`.
Can I trigger actions (e.g., Slack alerts) when LDAP syncs start or fail?
Yes, use the expanded event system. Listen for `LdapSyncStarted`, `LdapSyncCompleted`, or `LdapSyncFailed` events in your `EventServiceProvider`. For example: `event(new LdapSyncFailed($sync));` will dispatch to listeners like Slack or logging services.
How do I map custom LDAP attributes to Eloquent fields dynamically?
Use the `AttributeMapper` class to define runtime transformations. For example, map `telephoneNumber` to `phone` with `$mapper->map('telephoneNumber', fn($value) => preg_replace('/[^0-9]/', '', $value))`. Configure this in your `LdapModel` boot method.
Are there alternatives to this package for LDAP in Laravel, and how does it compare?
Alternatives include `adldap2-laravel` (simpler but less feature-rich) and `phpLDAPadmin` (web-based, not Laravel-native). This package stands out for its Eloquent-like models, incremental syncs, and event-driven architecture. It’s ideal for complex multi-domain setups, while alternatives may suffice for basic auth.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai