updates for active directory now with docs, noiw with microsoft AD sync

This commit is contained in:
Mark Gregory
2026-11-12 12:40:33 +00:00
parent 9404c7a210
commit 7e8bd50caa
+30 -1
View File
@@ -2,6 +2,24 @@
Run the same scenarios independently against [Samba AD](samba-ad.md) and [Microsoft AD DS](microsoft-ad.md). Record the application commit, directory version, date, and result for each run.
## Choose the directory in `.env`
The application uses one LDAP connection at a time. Keep exactly one of the `# Samba DC` and `# Microsoft AD` blocks enabled. The Microsoft AD block is active in the local checkout. To switch, comment out all assignments in the active block and uncomment all assignments in the other one. The shared settings above both blocks control the connection name, logging, timeout, SASL, scheduled sync, and the local administrator.
- **Samba DC** uses the local Docker LDAPS mapping on port 1636. The LDAPS host must match the certificate. Set the CA path to the Samba CA and confirm that the bind account can read the sync OU.
- **Microsoft AD** uses the domain controller's DNS hostname on port 636. Set the CA path to the PEM that establishes trust in that controller and use a read-only bind account.
- Both blocks use `LDAP_TLS=true` and `LDAP_STARTTLS=false` for LDAPS. `LDAP_BASE_DN` identifies the directory naming context. `AD_SYNC_BASE_DN` limits synchronization to the selected OU. Keep the bind password in the environment and keep it out of shared docs and logs.
After switching, run `php artisan config:clear` and confirm the connection and search scope with `php artisan ad:sync --email --dry-run`. The command records audit history. Restart any long-running application processes that retain the previous configuration.
## What the module does
- Reads paged LDAP snapshots, normalizes binary `objectGUID` values, and uses the `userAccountControl` disable bit. Incomplete snapshots and overlapping runs are rejected.
- Matches and updates users by their directory GUID within the configured scope. With `--email`, it can link an existing Laravel user by email. Creating a missing Laravel user requires `--create-missing`.
- Blocks sign-in and existing sessions for disabled managed users and supports reactivation when the directory account is enabled again. Missing-user deactivation requires explicit approval and is bounded. The local administrator can preview and apply the reviewed changes from the sync status screen.
- Provides dry runs, audit history, and console diagnostics. `--debug` displays normalized sync data and `-dd` displays selected LDAP properties. Scheduled runs can be enabled at ten-minute intervals.
- Owns all three feature test files under `Modules/ActiveDirectory/Tests/Feature`. PHPUnit includes the directory in its Feature suite, and Pest applies the shared Laravel test case and database refresh. The move preserved all test contents.
## Test setup
- Use a dedicated sync OU and a disposable Laravel database for each directory. Disable scheduled sync during manual testing.
@@ -14,7 +32,7 @@ Run the same scenarios independently against [Samba AD](samba-ad.md) and [Micros
From the project root:
```sh
php artisan test tests/Feature/DirectorySyncTest.php tests/Feature/ActiveDirectoryModuleTest.php --compact
vendor/bin/pest --testsuite=Feature --filter 'ActiveDirectoryModuleTest|DirectorySyncTest|DirectorySyncAdminTest'
php artisan test --compact
vendor/bin/pint --test
git diff --check
@@ -68,3 +86,14 @@ Run the disable and enable commands at their respective steps so Laravel can obs
| Microsoft AD DS | | | | |
Previous Samba runs exercised LDAPS, diagnostics, import of a disabled user, and subsequent reactivation. A live Windows AD DS run is pending.
### Checkout verification on 12 November 2026
Laravel's dotenv parser confirmed that reorganizing the file preserved the effective application settings. The Samba profile also parsed with all required LDAP fields. The obsolete `AD_HOST`, `AD_PORT`, `AD_BASE_DN`, `AD_USERNAME`, `AD_PASSWORD`, `AD_USE_SSL`, `AD_USE_TLS`, and `LDAP_SSL` keys were removed because the current LDAP configuration uses the profile keys above.
| Suite | Passed | Assertions |
| --- | ---: | ---: |
| Active Directory feature tests | 33 | 219 |
| Full Pest suite | 72 | 314 |
Both suites exited with status 0. The automated checks cover the shared sync behavior. This run did not contact either domain controller. Use the live checklist above to verify each directory's certificate, bind, scope, and account lifecycle.