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

LDAPRecord is an LDAP directory and Active Directory ORM for Laravel and PHP. It provides fluent models, query builder, authentication and user sync, event-driven operations, and easy integration with Laravel apps for managing and searching directory entries.

View on GitHub
Deep Wiki
Context7

A fully-featured LDAP framework.

Frequently asked questions about Ldaprecord
How do I integrate LDAPRecord with Laravel’s built-in authentication system?
LDAPRecord supports Laravel’s `Authenticatable` contract, so you can use it with `Auth::guard('ldap')->attempt()` after configuring the `LdapAuthServiceProvider`. Define a model (e.g., `User extends LdapRecord`) and bind it in `AuthServiceProvider`. The package handles LDAP-specific logic while leveraging Laravel’s auth scaffolding.
Does LDAPRecord work with Laravel 10/11, or only newer versions?
LDAPRecord is actively maintained for Laravel 10, 11, and 12, with backward compatibility for older versions (e.g., 9.x via v3.x). Check the [release notes](https://github.com/DirectoryTree/LdapRecord/releases) for version-specific Laravel support. PHP 8.1+ is required for v4.0+, while v3.x supports PHP 7.4+.
Can I test LDAPRecord without a real LDAP server?
Yes, LDAPRecord includes `DirectoryFake`, a mock LDAP server for unit and feature tests. Configure it in your `phpunit.xml` or tests by extending `DirectoryFakeTestCase`. This eliminates dependency on external LDAP instances during CI/CD, speeding up test suites.
How do I handle custom LDAP attributes (e.g., binary GUIDs or multi-valued fields)?
Use Eloquent’s `$casts` property to map custom attributes. For binary fields like GUIDs, set `protected $casts = ['guid' => 'binary']`. Multi-valued attributes (e.g., `memberOf`) are automatically handled as arrays. Refer to the [attribute casting docs](https://github.com/DirectoryTree/LdapRecord#attribute-casting) for edge cases.
What’s the performance impact of using LDAPRecord vs. raw PHP LDAP functions?
LDAPRecord adds a thin ORM layer, introducing ~5–15ms overhead per query compared to raw `ldap_*` functions. For latency-sensitive operations (e.g., authentication), benchmark critical paths. Use `Ldap::DEBUG_PACKETS` to profile queries and optimize filters (e.g., avoid nested `whereIn` with empty arrays).
How do I configure multiple LDAP connections (e.g., AD for prod, OpenLDAP for dev)?
Define connections in `config/ldap.php` with environment-specific settings (e.g., `LDAP_HOST`, `LDAP_BASE_DN`). Use `Ldap::connection('openldap')` to switch contexts dynamically. The package supports failover and connection pooling, ideal for multi-environment deployments.
Does LDAPRecord support syncing LDAP data to a local database (e.g., MySQL)?
Yes, LDAPRecord models extend Eloquent, so you can sync LDAP data to a local database by defining `protected $syncable = true` and using `sync()` or `syncWithoutDetectingChanges()`. This enables hybrid workflows (e.g., offline access) while keeping LDAP as the source of truth.
What are the common TLS/SSL issues when connecting to LDAP/AD, and how do I fix them?
Common issues include certificate validation failures or `ldap_start_tls()` timeouts. Configure `allow_insecure_password_changes` in your connection settings if needed, or use `Ldap::setOption(Ldap::OPT_PROTOCOL_VERSION, 3)` for LDAPv3. For AD, ensure `LDAP_OPT_REFERRALS` is disabled if not needed.
Are there alternatives to LDAPRecord for Laravel, and when should I choose them?
Alternatives include `adldap2/adldap2-laravel` (AD-focused) or `php-ldap/php-ldap` (raw LDAP). Choose LDAPRecord if you need Eloquent-like models, event-driven ops, or multi-LDAP support. Use raw LDAP for performance-critical or schema-flexible apps, or `adldap2` for AD-specific features like group membership caching.
How do I debug complex LDAP queries or authentication failures in production?
Enable debug modes with `Ldap::DEBUG_FILTER` or `Ldap::DEBUG_PACKETS` in your `.env` (e.g., `LDAP_DEBUG=1`). Logs will show raw LDAP queries and responses. For auth failures, check `auth.failed` events or inspect the `LdapRecord` model’s `getAuthIdentifier()` method to ensure correct attribute mapping.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony