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.
Identity & Access Management (IAM) Systems: Enables seamless integration of LDAP/Active Directory with Laravel applications, reducing reliance on custom LDAP libraries or third-party SaaS solutions (e.g., Okta, Azure AD). Supports build vs. buy decisions by providing a maintainable, open-source alternative.
Enterprise Authentication: Accelerates development of SSO (Single Sign-On), user provisioning, and directory synchronization features, aligning with roadmaps for internal tools, HR systems, or customer portals.
Legacy System Modernization: Facilitates migration of monolithic PHP/LDAP applications to Laravel by standardizing LDAP interactions with Eloquent-like syntax.
ldap_connect() with a Laravel model using LdapRecord.Compliance & Security: Addresses GDPR, HIPAA, or FERPA requirements by enabling granular LDAP attribute access (e.g., lastLogin, accountStatus) without exposing raw directory data.
userPassword via Laravel policies.Multi-Tenant SaaS: Supports tenant-specific LDAP configurations (e.g., per-tenant base DNs) via Laravel’s service container bindings.
Developer Productivity: Reduces boilerplate for LDAP operations by providing Eloquent-like syntax, query builders, and Laravel integrations (e.g., caching, observers).
User::where('department', 'IT')->get().Testing & Debugging: Includes tools like DirectoryFake for unit testing and granular debug levels (e.g., DEBUG_FILTER, DEBUG_PACKETS) to simplify troubleshooting.
Avoid if:
adldap2.ldap_* functions.Consider if:
CanAuthenticate trait).mail, memberOf, lastLoginTime)."LdapRecord is a strategic investment to modernize our LDAP integration without sacrificing control or incurring licensing costs. Here’s why it aligns with our goals:
Cost Efficiency:
Speed to Market:
Scalability:
Compliance & Security:
userPassword, telephoneNumber) to meet GDPR/HIPAA requirements.Future-Proofing:
Recommendation: Approve a proof-of-concept (PoC) for our [Project X] LDAP integration to validate the package’s fit. If successful, prioritize it for the next release cycle."*
"LdapRecord is a high-leverage tool for LDAP integration in Laravel, offering these technical advantages:
Eloquent-Like Syntax:
User::where('department', 'Engineering')->get() instead of raw LDAP filters.retrieved, saved).Seamless Laravel Integration:
CanAuthenticate trait), caching, and service containers.Auth::attempt(['username' => $dn, 'password' => $password]) with LDAP-backed users.Performance Optimizations:
whereIn queries (v3.8.5).Debugging & Testing:
DEBUG_FILTER, DEBUG_PACKETS) for troubleshooting.DirectoryFake for unit testing without external LDAP dependencies.Active Maintenance:
| Challenge | Mitigation |
|---|---|
| Abstraction Overhead | Benchmark against raw ldap_* functions; use only for CRUD-heavy workflows. |
| TLS/SSL Configuration | Set allow_insecure_password_changes carefully in config. |
| Attribute Casting | Use custom casts for binary data (e.g., objectSid). |
| Learning Curve | Provide internal docs comparing LdapRecord to raw LDAP for the team. |
Group or OrganizationalUnit) to validate integration.Example Workflow:
// Before (Raw LDAP)
$ldap = ldap_connect('ldap://server');
ldap_bind($ldap, $dn, $password);
$result = ldap_search($ldap, 'ou=users,dc=company', '(mail=*)');
$entries = ldap_get_entries($ldap, $result);
// After (LdapRecord)
User::where('mail', 'like', '%@company.com')->get();
Tools to Leverage:
DirectoryFake for testing.DEBUG_PACKETS for LDAP protocol-level debugging."LdapRecord enhances our LDAP security posture by:
Granular Attribute Access:
userPassword, homeDirectory) via Laravel policies or attribute casting.telephoneNumber from non-HR users.**
How can I help you explore Laravel packages today?