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.
LdapRecord provides a Eloquent-like interface for LDAP operations, making it a natural fit for Laravel applications. It maps LDAP records to Eloquent models, enabling familiar CRUD operations (e.g., User::find(), Group::create()) while abstracting LDAP-specific complexities (e.g., DN formatting, filters).Query\Builder mirrors Laravel’s Eloquent query builder, supporting where clauses, joins (via hasOne, belongsTo), and relationships, reducing cognitive load for developers.CanAuthenticate trait and Laravel auth integration enable seamless LDAP-backed authentication, aligning with Laravel’s security ecosystem (e.g., Auth::attempt()).saved, deleted) for LDAP operations, enabling hooks for logging, notifications, or auditing.DirectoryFake). Minimal boilerplate required for basic integration.insertAndGetDn).andFilter/orFilter (fixed in v4.0.1) and base DN substitution (v3.3.0+) simplify queries.chunk() and cursor() methods optimize large dataset retrieval.LDAP_DEBUG_* constants (v3.7.2) and DirectoryFake for testing.| Risk | Impact | Mitigation Strategy |
|---|---|---|
| Timestamp Handling | High (v3.8.4, v4.0.4) | Use ldap:timestamp casting; validate timestamps in tests. |
| TLS/SSL Misconfiguration | Medium | Enforce use_ssl = true in config; monitor ldap_start_tls() errors (fixed in v3.6.0). |
| Attribute Casting Issues | Medium | Extend AttributeCast for custom types (e.g., objectSid, binaryGUID). |
| Base DN Errors | Low | Use {base} syntax in queries (e.g., whereMemberOf); test with DirectoryFake. |
| Performance Overhead | Low | Cache frequent queries; use chunk() for large datasets. |
| Laravel Version Lock-in | Low | Monitor Laravel 14 support; use feature flags for breaking changes. |
| Schema Rigidity | Medium | Validate schema compatibility early; use Attribute casting for non-standard fields. |
| Debugging Complexity | Medium | Enable LDAP_DEBUG_FILTER or LDAP_DEBUG_PACKETS in staging. |
LDAP Environment Stability:
Authentication Workflow:
Auth::guard('ldap')) or supplemental (e.g., user provisioning)?CanAuthenticate and BindException handling.Performance SLAs:
ldap_* functions may outperform this ORM.DirectoryFake; cache frequent queries.Multi-Tenancy Needs:
Testing Strategy:
DirectoryFake suffice?DirectoryFake for unit tests; supplement with end-to-end tests against a real directory.Upgrade Path:
Custom Attributes:
AttributeCast or Attribute classes for unsupported types.Compliance Requirements:
php-ldap extension (enabled by default in most Laravel deployments).DirectoryFake.| Phase | Actions | Tools/Dependencies |
|---|---|---|
| Assessment | Audit LDAP schema; identify critical models (e.g., User, Group). |
DirectoryFake, ldapsearch |
| Pilot | Implement a non-critical model (e.g., Department) with basic CRUD. Test with DirectoryFake. |
Laravel Tinker, Pest |
| Core Integration | Replace custom LDAP logic with LdapRecord models. Migrate auth to CanAuthenticate. |
Laravel Auth, ldaprecord-laravel |
| Advanced Features | Add relationships (e.g., User belongsTo Group), chunking, or caching. |
Eloquent Relationships, Laravel Cache |
| Optimization | Profile queries; implement caching for frequent operations (e.g., group membership checks). | Laravel Debugbar, Blackfire |
| Production Rollout | Gradually replace endpoints; monitor LDAP connection metrics. | Sentry, Laravel Horizon (for queue monitoring) |
whereMemberOf, objectSid).DirectoryFake.whereIn: Fixed in v3.8.5.ldap_start_tls() errors; use allow_insecure_password_changes cautiously.How can I help you explore Laravel packages today?