Skip to content
Back to skills

Samba Active Directory

BSecurity

Use when setting up or running Samba as an AD domain controller or SMB file server — samba-tool domain provision, Kerberos and DNS backends, FSMO, SYSVOL replication, GPO, joining Windows or Linux clients, share ACLs and VFS, idmap, Windows software deployment.

  • 4 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 9, 2026
developmentrustgoshellbashdockergitfrontendbackendsecurity

Works with

  • cli

Security analysis

B75/100
  • criticalAccesses sensitive system or user directories

Pro scans all 4 files and shows the line behind each finding

Scanned November 28, 2026

npx -y skills add Getty/skills --skill samba-active-directory --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Samba Active Directory?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Samba Active Directory
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/getty-samba-active-directory/badge)](https://www.skillsdirectory.com/skills/getty-samba-active-directory)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: samba-active-directory
description: "Use when setting up or running Samba as an AD domain controller or SMB file server — samba-tool domain provision, Kerberos and DNS backends, FSMO, SYSVOL replication, GPO, joining Windows or Linux clients, share ACLs and VFS, idmap, Windows software deployment."
---

# Samba Active Directory

Samba 4 is the only open-source, production-ready alternative to Windows Server AD: LDAP directory, Kerberos KDC, DNS, GPO storage, FSMO. A host runs in **exactly one** of four mutually exclusive modes (set via `server role` or at provisioning time).

**Rule of thumb: DC ≠ file server.** File servers belong on a **domain member**, never on the DC. The DC runs the all-in-one daemon **`samba`** — and **not** `smbd/nmbd/winbindd`; a member starts exactly the opposite, `smbd/nmbd/winbindd` and **never** `samba`. This is the most common mix-up.

## Operating modes

| `server role` | Role | Service | When |
|---|---|---|---|
| `active directory domain controller` | Provides the domain (LDAP, KDC, DNS, SYSVOL, GPO, FSMO). | `samba` | Heart of the domain. |
| `member server` | Domain member, serves file/print, uses domain users for ACLs. | `smbd`+`nmbd`+`winbindd` | **The place for file servers.** |
| `standalone server` | File/print without a domain, local `passdb`. | `smbd`+`nmbd` | Standalone setup, guest share. |
| `classic primary domain controller` | NT4 model (no Kerberos/LDAP). | — | **Obsolete.** Only `samba-tool domain classicupgrade` for migration. Do not set up new. |

## Provisioning an AD DC

Fresh OS install, **static IP** outside the DHCP pool, clean `/etc/hosts` (FQDN+short name → LAN IP, **not** 127.0.0.1), `systemd-resolved`/`resolvconf` auto-override off. Remove the packaged `smb.conf` first.

```bash
mv /etc/samba/smb.conf /etc/samba/smb.conf.initial   # otherwise provision fails

samba-tool domain provision \
    --server-role=dc \
    --use-rfc2307 \
    --dns-backend=SAMBA_INTERNAL \
    --realm=AD.EXAMPLE.COM \
    --domain=EXAMPLE \
    --adminpass='…' \
    --option="interfaces=lo eth0" --option="bind interfaces only=yes"
```

- `--realm` = Kerberos realm/DNS zone in **UPPERCASE** (`AD.EXAMPLE.COM`). **Cannot be renamed after provisioning** — choose carefully. **No `.local`** (collides with mDNS/Avahi). Never the public top-level domain, always a dedicated subdomain.
- `--domain` = NetBIOS name ≤ 15 characters, one word, no dot.
- `--dns-backend` = `SAMBA_INTERNAL` (default, works out of the box, forwarder via `dns forwarder=`) or `BIND9_DLZ` (only if AXFR/views/DNSSEC/split-horizon are needed). `NONE`/`BIND9_FLATFILE` are unsupported. Switchable at any time: `samba_upgradedns --dns-backend=…`.
- `--use-rfc2307` = **always set** (uidNumber/gidNumber in the schema; prerequisite for the Unix-attributes tab and idmap `ad`). Retrofitting = manual schema work.
- `--function-level`, `--adminpass` etc. — details in `references/provisioning.md`.

Afterwards: **copy** the `krb5.conf` generated by Samba to the OS location (no symlink — `private/` is root-only since 4.7), set `/etc/resolv.conf` to `nameserver <DC-IP>` + `search ad.example.com`, then start `samba`. **Time is Kerberos-critical** (tolerance 5 min): `chrony`/`ntpd` with `ntpsigndsocket /var/lib/samba/ntp_signd/` for signed NTP replies to Windows clients.

Basic checks:
```bash
samba-tool domain info 127.0.0.1
samba-tool domain level show
host -t SRV _ldap._tcp.ad.example.com.         # the DC must answer
smbclient -L localhost -N                # must show sysvol + netlogon
kinit administrator                      # Kerberos ticket
```

Without working SRV records (`_ldap._tcp`, `_kerberos._udp`) no client finds the domain — the DC becomes the **DNS resolver of all joined clients**.

## Administration

`samba-tool` covers almost everything headless:
```bash
samba-tool user create <name>   / setpassword / disable / list
samba-tool group add / addmembers <grp> <user1>,<user2>
samba-tool computer / ou create OU=…
samba-tool dns add <dc> ad.example.com <name> A <ip> -U administrator
samba-tool fsmo show                              # 5 roles; transfer|seize --role=…
samba-tool gpo listall / create "Name" / backup <GUID> / admxload
samba-tool ntacl sysvolcheck / sysvolreset        # fix NT ACLs on SYSVOL
samba-tool domain passwordsettings show
```

From a **domain-joined Windows client** (Pro/Enterprise) the **RSAT** tools work seamlessly, since Samba stores a real AD schema: **ADUC** (users/groups/OUs/Unix tab), **GPMC** (GPOs — the GPO **editor** runs **only** on Windows, the CLI can only save/link), **DNS Manager**, **Sites & Services**. Fill the ADMX Central Store with `samba-tool gpo admxload`.

## Multiple DCs + the SYSVOL gap

From the 2nd DC on, **do not provision, join**:
```bash
samba-tool domain join ad.example.com DC -U administrator \
    --dns-backend=SAMBA_INTERNAL --option='idmap_ldb:use rfc2307 = yes'
samba-tool drs showrepl        # LDAP replicates automatically via DRS
```

> **The gap:** DRS replicates the **LDAP DB automatically, but NOT SYSVOL** — Samba has **no DFS-R/FRS**. With multiple DCs, SYSVOL/GPOs drift apart.

Workaround — sync SYSVOL from the "leading" DC via a systemd timer, carry the ACLs along, then run `sysvolreset`:
```bash
rsync -aAX --delete /var/lib/samba/sysvol/ dc2:/var/lib/samba/sysvol/   # --acls/xattr!
ssh dc2 samba-tool ntacl sysvolreset
```
`osync`/`unison` for bidirectional, equal-rights DCs. **Irrelevant with one DC** — only needed from the second one on (failover). See `references/provisioning.md`.

## File server (domain member)

Join first, then shares. Why not on the DC: SMB signing is enforced there, only `acl_xattr` (no POSIX ACLs), and the `idmap config` lines have no effect.

```bash
net ads join -U administrator            # classic (winbind stack) — for file servers
```

`smb.conf` (member file server), core:
```ini
[global]
    security = ADS
    workgroup = EXAMPLE
    realm = AD.EXAMPLE.COM
    idmap config * : backend = tdb
    idmap config * : range = 3000-7999
    idmap config EXAMPLE : backend = rid
    idmap config EXAMPLE : range = 10000-999999
    winbind use default domain = yes
    vfs objects = acl_xattr
    map acl inherit = yes

[data]
    path = /srv/samba/data
    read only = no
    vfs objects = acl_xattr shadow_copy2 recycle
```

- **Mount the filesystem** with `acl,user_xattr`. `vfs_acl_xattr` stores the full Windows NT ACL in `security.NTACL` → permissions can be set 1:1 from Explorer.
- **VFS modules** (order matters): `shadow_copy2` = "Previous Versions" tab (maps snapshots to VSS), `recycle` = server-side recycle bin, `fruit` = macOS/Time Machine, `full_audit` = access logging. **Pitfall:** `vfs objects = recycle` alone switches off the defaults → explicitly `dfs_samba4 acl_xattr recycle`.
- **idmap backend** — which one when:

  | Backend | How | When |
  |---|---|---|
  | **`rid`** | UID/GID algorithmically from RID+offset, deterministic, identical on every member, no AD write access. | **Default for a small setup.** |
  | **`autorid`** | like `rid`, ranges assigned automatically per domain. | Multi-domain/trust. |
  | **`ad`** | UID/GID **read** from RFC2307 attributes (`uidNumber`) in AD, maintained manually. | IDs exactly identical everywhere + NFS interop / control shells in AD. |

  Ranges must **never overlap**; `*` always via `tdb`. Full share/ACL details: `references/fileserver.md`.

## Joining clients

- **Windows** (Pro/Enterprise, **Home cannot join**): point the client's DNS at the **DC** (via DHCP option), then join the domain. After that GPOs apply fully, including GPO software deployment.
- **Linux:** `realm join ad.example.com -U administrator` (uses **SSSD**) **or** `net ads join` (**winbind**). **Rule of thumb:** host is also a Samba **file server** → **winbind** (SMB needs the SID mappings). Pure login host (SSH) → **SSSD** is more convenient (caching, offline login). Configure NSS/PAM accordingly (`passwd: files winbind` or sss).

## Central software deployment

Two separate concepts: **(1) app streaming** (app runs on the server, client sees a window) vs. **(2) distribution** (defined centrally, installed locally on each client). Decision table:

| Way | Type | Prerequisite | Cost | Fit | Samba DC? |
|---|---|---|---|---|---|
| **winget / Chocolatey via GPO startup script** | (2) | Domain, script in SYSVOL | **free** | ●●● | **Yes, recommended.** The GPO only delivers the script, the package manager runs locally, covers arbitrary .exe/Store apps. |
| **GPO Software Installation (MSI)** | (2) | Domain, MSI on a share | free | ●○○ | Yes, but **`.msi` only** (no .exe), slow, brittle — fallback only. |
| **PDQ Deploy & Inventory** | (2) | Windows host for the console | ~$1,950/year | ●●○ | Yes (needs no domain). Most comfortable way for (2), price is the catch. |
| **RDS / RemoteApp** | (1) | **Windows Server + RDS CALs** | expensive (CALs on top) | ●●○ | Server **must** be Windows; RDS **authenticates** against Samba AD though. Only option that fulfils (1) literally. |
| **Kasm Workspaces CE** | (1) | Docker host | free (≤5 sessions) | ●●● Linux/browser, ●○○ Win GUI | Independent of the DC. Free streaming alternative for Linux/web apps. |
| **Apache Guacamole** | Gateway | Docker + RDP/RemoteApp backend | free | ●●○ | Browser frontend; delivers no app itself, needs RDS or xrdp behind it. |

**Key point:** For the 80% case **winget/Choco via GPO** is enough — free, fully Samba-compatible. **Only RDS** needs a real Windows Server licence + CALs (the one cost trap). A Windows client OS allows **only one** RDP session (no legitimate RemoteApp). Additionally: home shares + drive mapping via GPO, folder redirection, FSLogix profiles (any SMB share, so Samba too). Full option matrix + phased recommendation: `references/software-deployment.md`.

## Pitfalls & versions

- **Realm cannot be changed after provisioning.** No `.local`. NetBIOS ≤ 15 characters.
- **No AD DC in Docker/LXC** — own network stack/systemd/tdb locking, becomes a DNS resolver, scans all interfaces in `host` network mode. Always a **dedicated VM**.
- **Debian 12 = Samba 4.17 (upstream dead)** — unsuitable for a DC. `bookworm-backports` provides 4.22.6, **Debian 13 = 4.22.x**, or **SAMBA+/SerNet** packages. Run a DC only on a **maintained** series.
- **Functional level:** default 2008 R2; can be raised up to **2016** (highest supported FL, Samba ≥ 4.20 on all DCs). Higher = "work in progress".
- **Run with CVE patches applied across the board.** `CVE-2025-10230` (WINS hook, CVSS 10.0) only with `wins support=yes`+`wins hook` → do not enable WINS at all. SMB1 off (default since 4.11), LDAPS/RPC signing on.

## Map of references

| Topic | File |
|---|---|
| Provision parameters, DNS backend comparison, Kerberos/FSMO/SYSVOL/time, functional level, multi-DC + SYSVOL rsync recipe, backup/restore | references/provisioning.md |
| Complete member `smb.conf`, POSIX vs. NT ACLs, all VFS modules, idmap in depth, home shares/roaming/FSLogix, client join (winbind vs SSSD) | references/fileserver.md |
| Full option matrix (A1–D3), phased recommendation phases 0–3, cost traps, Windows client 1-session limit | references/software-deployment.md |

Files in this skill

  • SKILL.md11.1 KB
  • references/fileserver.md5.4 KB
  • references/provisioning.md6.4 KB
  • references/software-deployment.md7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.