Files
ad_testbed/docs/samba-ad.md
T

62 lines
2.2 KiB
Markdown

# Samba Active Directory and Laravel sync
The local Samba AD domain is `ad.test`. Docker runs it in the `samba-ad` container. Laravel connects to LDAPS at `127.0.0.1:1636` and searches `OU=LaravelSync,DC=ad,DC=test`.
Check that the container is running and confirm its published ports:
```sh
docker ps --filter name=samba-ad
docker port samba-ad
```
## Directory accounts
Set the AD `mail` attribute to the email address used in Laravel. Create a new test account directly in the sync OU with:
```sh
docker exec -it samba-ad samba-tool user create mark.gregory \
--given-name=Mark --surname=Gregory \
--mail-address=[email protected] --userou='OU=LaravelSync'
```
For an existing account in the default Users container, move it into scope:
```sh
docker exec samba-ad samba-tool user move mark.gregory 'OU=LaravelSync,DC=ad,DC=test'
```
Check the account and toggle its enabled state:
```sh
docker exec samba-ad samba-tool user show mark.gregory --attributes=mail,userAccountControl
docker exec samba-ad samba-tool user disable mark.gregory
docker exec samba-ad samba-tool user enable mark.gregory
```
## Sync and diagnostics
Run these commands from the Laravel project directory:
```sh
php artisan ad:sync --email --dry-run -dd
php artisan ad:sync --email --dry-run -vvv --debug
php artisan ad:sync --email
```
- `-dd` and `--dump-ad` print AD properties for each returned account, including distinguished name, sign-in names, group memberships, account control, and timestamps when present.
- `--debug` prints each returned AD account, including names, email addresses, GUIDs, and account flags. Treat that output as directory data.
- `-v`, `-vv`, and `-vvv` increase sync detail.
- `--email` matches existing Laravel users by email. Add `--create-missing` explicitly to import absent users.
- `--dry-run` previews changes to user records. The sync still records audit history.
## Missing LDAPS CA certificate
If the configured CA file is missing, restore the public certificate from Samba and retry:
```sh
docker cp samba-ad:/var/lib/samba/private/tls/ca.pem storage/app/private/ldap-samba-ca.pem
php artisan ad:sync --email --dry-run -dd
```
The `LDAP_TLS_CA_CERT` setting must point to that local file.