updates for active directory now with docs
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# Microsoft Active Directory Domain Services
|
||||
|
||||
Use a Windows Server AD DS domain controller and a dedicated LDAP read account. The sync uses standard AD DS LDAP attributes and paged searches. This guide uses `corp.example.net` as an example domain.
|
||||
|
||||
## Configure LDAP over TLS
|
||||
|
||||
Use a domain controller hostname that matches its certificate. The Laravel host needs DNS resolution, TCP access to port 636, the PHP LDAP extension, and trust in the issuing CA. If the CA is private, place the public CA chain in a readable PEM file and point `LDAP_TLS_CA_CERT` to it. Keep the bind password in the deployment secret store or the local environment.
|
||||
|
||||
```dotenv
|
||||
LDAP_CONNECTION=default
|
||||
LDAP_HOST=dc01.corp.example.net
|
||||
LDAP_PORT=636
|
||||
LDAP_TLS=true
|
||||
LDAP_STARTTLS=false
|
||||
LDAP_SASL=false
|
||||
LDAP_USERNAME="svc-laravel-sync@corp.example.net"
|
||||
LDAP_PASSWORD="<bind password>"
|
||||
LDAP_TLS_CA_CERT="/absolute/path/to/ad-ca-chain.pem"
|
||||
LDAP_BASE_DN="DC=corp,DC=example,DC=net"
|
||||
AD_SYNC_BASE_DN="OU=LaravelSync,DC=corp,DC=example,DC=net"
|
||||
AD_SYNC_SCHEDULED=false
|
||||
```
|
||||
|
||||
This example uses a simple bind inside TLS. Confirm the bind works under your organisation's LDAP policy before enabling scheduled sync. Reload Laravel's configuration cache using your normal deployment process after changing settings. Use `ldp.exe` to independently verify the LDAPS endpoint if needed. [Microsoft LDAPS certificate setup](https://learn.microsoft.com/windows-server/identity/ad-ds/configure-ldap-signing-certificates) · [LDAP signing](https://learn.microsoft.com/windows-server/identity/ad-ds/ldap-signing)
|
||||
|
||||
## Prepare the sync OU
|
||||
|
||||
Put test users in the configured OU. Give the bind account permission to read those users and their required attributes. Every returned user needs a unique, valid `mail` address and a usable `displayName` or `cn`. A missing or duplicate address rejects the whole snapshot. Laravel matches by `objectGUID` first. With `--email`, an existing eligible Laravel user can be linked by `mail`.
|
||||
|
||||
The LDAP filter combines `objectCategory=person` with `objectClass=user`. AD DS supplies the paged-results control used by the sync. The disabled state comes from the `ACCOUNTDISABLE` bit (`0x0002`) in `userAccountControl`. Use a dedicated OU on one domain controller's domain for the first run. The sync rejects incomplete pages and referrals. [User search filter](https://learn.microsoft.com/windows/win32/ad/querying-for-users) · [AD DS LDAP controls](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea) · [Account control flags](https://learn.microsoft.com/troubleshoot/windows-server/active-directory/useraccountcontrol-manipulate-account-properties)
|
||||
|
||||
## Verify against Windows AD
|
||||
|
||||
On a Windows admin workstation with the Active Directory PowerShell module, inspect the test account and its OU:
|
||||
|
||||
```powershell
|
||||
Get-ADUser -Identity 'sync-test' -Server 'dc01.corp.example.net' -Properties mail,userAccountControl |
|
||||
Select-Object DistinguishedName,ObjectGUID,mail,Enabled,userAccountControl
|
||||
```
|
||||
|
||||
On the Laravel host, preview the same account:
|
||||
|
||||
```sh
|
||||
php artisan ad:sync --email --dry-run -dd
|
||||
php artisan ad:sync --email --dry-run -vvv --debug
|
||||
```
|
||||
|
||||
Compare the GUID, mail, distinguished name, and account control with PowerShell. `-dd` (also `--dump-ad`) prints selected AD properties as returned by LDAP, with the binary GUID rendered as text. Optional fields appear only when returned by the server. `--debug` prints the account data Laravel uses for the sync.
|
||||
|
||||
For the live test, use a dedicated Laravel database and a dedicated AD test account:
|
||||
|
||||
1. Create a Laravel user with the same email and run `php artisan ad:sync --email`. Confirm the existing row gains the AD GUID. To test importing instead, use `--create-missing` explicitly after reviewing a dry run.
|
||||
2. Disable the test account with `Disable-ADAccount -Identity 'sync-test' -Server 'dc01.corp.example.net'`. Run the email sync again. Confirm Laravel records `directory_disabled` and blocks login.
|
||||
3. Run `Enable-ADAccount -Identity 'sync-test' -Server 'dc01.corp.example.net'`, then sync again. Confirm one reactivation and verify the Laravel login check.
|
||||
4. For a scope larger than 500 users, compare the `-dd` dry-run result count with an AD query over the same OU to verify paging under the target controller's policies.
|
||||
|
||||
The application tests cover the sync logic and LDAP paging with fixtures. The live integration in this project was exercised against Samba AD. Run the steps above on the target Windows domain controller to confirm its certificate, bind policy, permissions, and directory data.
|
||||
Reference in New Issue
Block a user