directorytree/ldaprecord-laravel
Integrate LDAP authentication and directory management into Laravel with LdapRecord. Configure connections, sync users and groups, run queries, and handle logins against Active Directory/OpenLDAP with clean, Laravel-friendly APIs and tooling.
config/ldap.php, critical for multi-tenant SaaS or hybrid AD/LDAP environments. The LdapConnectionManager remains unchanged, ensuring no architectural debt.LdapAuthProvider). This preserves gradual migration paths (e.g., pilot LDAP for enterprise users while keeping consumer users in DB).RulePassed, RuleFailed, LoginFailed) remain intact, enabling audit logging, MFA hooks, or custom workflows without modifying the package.Auth::guard('ldap')). No changes to app/Providers/AuthServiceProvider.User::where('mail', 'like', '%@company.com')) and relationships (e.g., hasMany for group memberships).ldap:browse, ldap:import) for admin workflows (e.g., bulk user sync).config/ldap.php; no core Laravel files are modified. Zero merge conflicts with upstream Laravel updates.directorytree/ldaprecord (v4.x+), which is actively maintained (last release: 2026-06-08).php-ldap and ext-ldap (PHP extensions), which are standard for LDAP workflows.| Risk Area | Severity | Mitigation | TPM Action |
|---|---|---|---|
| LDAP Schema Mismatch | High | Non-standard LDAP schemas may require custom attribute handlers. | Pre-integration: Audit target LDAP schemas; validate with Directory Emulator. |
| Performance at Scale | Medium | LDAP queries may lag with >10K users. | Benchmark: Test with ldap:browse; optimize with connection pooling (config/ldap.php). |
| Password Sync Complexity | Medium | Custom password policies (e.g., expiry) may conflict with AD. | Design: Use password_column: false for read-only LDAP; document tradeoffs. |
| Multi-Tenant Isolation | Medium | Shared LDAP connection may leak tenant data. | Architecture: Scope connections by tenant ID (e.g., config/ldap.connections.tenant_{id}). |
| Event Overhead | Low | Excessive logging events (RulePassed) may impact performance. |
Configure: Set logging.level to debug/info in config/ldap.php. |
| Upgrade Path | Low | v4.x introduces minor breaking changes (e.g., rehashPasswordIfRequired). |
Plan: Test upgrade in staging; use composer why-not to validate compatibility. |
LdapImporter config.)merge, ldap_wins)?RulePassed/RuleFailed events.)php-ldap and ext-ldap (standard for LDAP workflows). Verify via:
php -m | grep ldap
ldap:browse, ldap:import) for admin workflows.LDAP_RECORD_EMULATOR=true in .env.| Phase | Action | Tools/Commands | Risk |
|---|---|---|---|
| Prep | Audit LDAP schema; validate with Directory Emulator. | composer require directorytree/ldaprecord-laravel + emulator tests. |
Low |
| Pilot | Implement LDAP auth for a single tenant/group. | Configure config/ldap.php; extend LdapAuthProvider. |
Medium (auth flow testing) |
| Hybrid Auth | Merge LDAP and DB auth (e.g., Auth::guard() logic). |
Custom AuthServiceProvider; test with php artisan auth:guard ldap. |
Medium (session handling) |
| Sync | Set up bulk imports (ldap:import) or real-time sync (e.g., queue listeners). |
LdapImporter with --resolve=merge; event listeners for user.created. |
High (data integrity) |
| Optimize | Tune connection pooling; add caching for frequent queries. | config/ldap.php; Laravel cache (e.g., Cache::remember). |
Low |
rehashPasswordIfRequired or validateCredentials.RulePassed, RuleFailed, or LoginFailed for custom logic.config/ldap.php for your connection.LdapAuthProvider (if custom logic is needed).AuthServiceProvider:
Auth::guard('ldap', function ($app) {
return new LdapAuthProvider($app['auth'], $app['config']['ldap']);
How can I help you explore Laravel packages today?