Download the PHP package ismailelbery/laravel-ldap-sync without Composer
On this page you can find all versions of the php package ismailelbery/laravel-ldap-sync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ismailelbery/laravel-ldap-sync
More information about ismailelbery/laravel-ldap-sync
Files in ismailelbery/laravel-ldap-sync
Package laravel-ldap-sync
Short Description Sync users from Active Directory OUs into a local Eloquent model, with live LDAP search and manager resolution.
License MIT
Informations about the package laravel-ldap-sync
Laravel LDAP Sync
An opinionated LDAP / Active Directory user synchronization package for Laravel. Sync users from multiple Organizational Units (OUs) into your local database on a schedule, with department mapping, attribute transformation, and full sync reporting β built on top of LdapRecord.
Designed for enterprise and government environments where Active Directory is the source of truth and your Laravel application needs a reliable, queryable local copy of users.
β¨ Features
- π Scheduled synchronization β run full or incremental syncs via Laravel's scheduler
- π’ Multi-OU support β search and sync across multiple base DNs / OUs in a single run
- π User search β search LDAP directly by username, name (EN/AR), email, or department with a fluent API
- π Manager resolution β get a user's direct manager or the full management chain up to the top
- ποΈ Department mapping β map LDAP OUs or attributes to local departments/teams
- π§ Attribute mapping β declarative config to map LDAP attributes to Eloquent columns (with custom transformers)
- π Arabic / UTF-8 safe β correct handling of Arabic display names and attributes
- π§Ή Stale user handling β disable, soft-delete, or flag users removed from AD
- π Sync reports β created / updated / disabled counts, with optional logging and notifications
- π§ͺ Dry-run mode β preview changes before touching your database
- πͺ Events β hook into
UserSynced,UserDisabled,SyncCompletedfor custom logic
π¦ Installation
Publish the config and migrations:
βοΈ Configuration
All connection settings live in your .env:
The published config/ldap-sync.php lets you define attribute mapping:
π Usage
Run a sync manually
Sync a specific OU only
Preview changes without writing (dry run)
Example output:
Schedule it
In routes/console.php (Laravel 11):
Listen to events
π User Search
Search Active Directory directly (live, not the local table) using the LdapUserSearch facade. All searches run across all configured OUs and merge + deduplicate results by objectguid.
Each result is returned as an LdapUserDto with a consistent shape regardless of AD schema quirks:
Search command
A quick CLI lookup is also included:
π Manager Resolution
Resolve reporting lines straight from the AD manager attribute.
This is particularly useful for approval workflows β route a request to a user's direct manager, or escalate up the chain automatically:
Note: Manager resolution requires the
managerattribute to be populated in your AD. The chain resolver guards against circular references and missing managers, returning the chain built so far rather than throwing.
π§± How It Works
- Connects to your LDAP/AD server using LdapRecord with the credentials in
config/ldap.php. - Iterates each configured OU, paginating results to safely handle large directories.
- For each entry, resolves the local user via the configured unique key (
objectguidby default β immune to renames and OU moves). - Applies attribute mapping and transformers, then creates or updates the Eloquent model.
- After all OUs are processed, applies the stale-user strategy to local users no longer present in AD.
- Fires events and writes a sync report.
π§ͺ Testing
The test suite uses LdapRecord's built-in directory emulator, so no real LDAP server is required.
πΊοΈ Roadmap
- [ ] Group β role synchronization (Spatie permissions bridge)
- [ ] Incremental sync via
whenChanged/ USN tracking - [ ] Photo (
thumbnailPhoto) sync to local storage - [ ] Web dashboard for sync history
π€ Contributing
Contributions are welcome! Please open an issue first to discuss what you would like to change, and make sure tests pass before submitting a PR.
π Security
If you discover a security vulnerability, please email [email protected] instead of using the issue tracker.
π License
The MIT License (MIT). See LICENSE.md for details.
Built with β by Ismail Elbery β born from years of syncing Active Directory users in Laravel government systems.
All versions of laravel-ldap-sync with dependencies
directorytree/ldaprecord-laravel Version ^3.0
spatie/laravel-package-tools Version ^1.16