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 Package

directorytree/ldaprecord

Integrate LDAP into Laravel with a fluent, ActiveRecord-style API. LdapRecord handles connections, queries, authentication, and directory operations across AD and OpenLDAP. Includes Laravel-ready features for config, models, and user syncing.

View on GitHub
Deep Wiki
Context7

A fully-featured LDAP ORM.

Frequently asked questions about Ldaprecord
How do I set up LdapRecord for Laravel authentication like Auth::attempt()?
Use the `CanAuthenticate` trait in your LDAP model (e.g., `User::class`). Configure the `auth` driver in `config/auth.php` to point to your LDAP connection, then call `Auth::guard('ldap')->attempt()`. The package handles binding and credential validation automatically.
Does LdapRecord support Laravel 13 and PHP 8.4?
Yes, LdapRecord v4.x is fully compatible with Laravel 11–13 and PHP 8.1–8.4. Check the [release notes](https://github.com/DirectoryTree/LdapRecord/releases) for version-specific features like `insertAndGetDn` in v4.0.0+.
Can I query nested LDAP groups or use complex filters (AND/OR) like Eloquent?
Absolutely. Use `whereMemberOf()` for groups and chain `orFilter()`/`andFilter()` for complex queries. Example: `User::where('department', 'IT')->orFilter('title', 'Admin')`. Nested filters were fixed in v4.0.1.
How do I test LDAP operations without hitting a real directory server?
Use `DirectoryFake`, a built-in testing tool. Mock connections in your tests with `DirectoryFake::fake()` and assertions like `DirectoryFake::assertBound()`. It simulates LDAP responses for unit/integration tests.
What’s the best way to handle multi-tenancy with separate LDAP base DNs?
Bind tenant-specific configurations to Laravel’s service container. Use `config(['ldap.connections.tenant1' => [...]])` per request or middleware. The package supports dynamic base DNs via `{base}` syntax in queries.
How do I debug LDAP connection issues or slow queries?
Enable debug constants like `LDAP_DEBUG_FILTER` or `LDAP_DEBUG_PACKETS` in your `.env`. For performance, use `chunk()` for large datasets or cache frequent queries with Laravel’s cache. Monitor TLS errors with `ldap_start_tls()`.
Does LdapRecord work with Active Directory (AD) or only OpenLDAP?
It supports both AD and OpenLDAP out of the box. AD-specific features like `objectSid` or `binaryGUID` require custom `AttributeCast` classes. Tested with AD 2016+ and OpenLDAP 2.4+. Schema flexibility is high but may need casting for non-standard fields.
Can I sync users between Laravel and LDAP bidirectionally?
Yes. Use Laravel’s `saved`/`deleted` events to trigger LDAP updates. Example: `User::saved(function ($user) { $user->ldapRecord()->save(); })`. For bulk syncs, leverage `chunk()` to avoid memory issues.
What are the alternatives to LapRecord for LDAP in Laravel?
Alternatives include `adldap2/adldap2-laravel` (simpler but less feature-rich) or `phpLDAPadmin` (web-based). LdapRecord stands out for its Eloquent-like API, Laravel integration (events, caching), and support for complex queries. Choose it for deep LDAP + Laravel synergy.
How do I handle custom LDAP attributes (e.g., binary data like `objectSid`)?
Extend `AttributeCast` in your model. Example: `protected $casts = ['objectSid' => 'binaryGUID'];`. For unsupported types, create a custom cast class implementing `AttributeCastInterface`. Check the [docs](https://github.com/DirectoryTree/LdapRecord#attribute-casting) for examples.
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