Sub topic 18
Joining Samba to a Domain
This chapter assumes you understand Linux users, groups, permissions, systemctl, and basic DNS and TCP/IP. It also assumes you have administrative access to an Active Directory (AD) domain. The Linux server must resolve the domain controller by DNS, and its clock must be synchronized with the domain. Kerberos, the authentication protocol commonly used by AD, rejects requests when clocks differ too much.
A domain member does not replace the domain controller. Samba uses the domain to authenticate users, while winbindd translates domain users and groups into identities that Linux can use.
Configure the domain member
Install Samba, Winbind, Kerberos client tools, and the NSS modules provided by your distribution. Package names differ between distributions. Configure /etc/krb5.conf with the correct realm if your package does not create it automatically.
The realm is usually the uppercase DNS domain. The workgroup is usually the short NetBIOS domain name.
# /etc/samba/smb.conf
[global]
security = ADS
realm = EXAMPLE.COM
workgroup = EXAMPLE
winbind use default domain = yes
winbind refresh tickets = yes
kerberos method = secrets and keytab
idmap config * : backend = tdb
idmap config * : range = 3000-7999
idmap config EXAMPLE : backend = rid
idmap config EXAMPLE : range = 10000-999999
template shell = /bin/bash
template homedir = /home/%U
[projects]
path = /srv/samba/projects
read only = no
valid users = @"EXAMPLE\Domain Users"The idmap settings assign stable Linux user and group IDs to domain identities. The ranges must not overlap with local or other domain ranges. Changing them later can make files appear owned by different users.
Check that DNS and Kerberos work before joining:
kinit [email protected]
klist
sudo testparm -s
sudo net ads join -U Administrator
sudo systemctl enable --now smb winbind
wbinfo -t
getent passwd alice
getent group "EXAMPLE\Domain Users"kinit obtains a Kerberos ticket. net ads join creates the computer account in AD. wbinfo -t tests the trust relationship, while getent confirms that Linux can resolve domain identities.
| Setting | Purpose |
|---|---|
| `security = ADS` | Uses Active Directory authentication |
| `realm` | Names the Kerberos realm |
| `idmap config` | Maps domain IDs to Linux IDs |
| `valid users` | Limits access to a domain group |
Domain membership does not grant every domain user access to every share. Continue to enforce access with share rules and filesystem permissions. For sensitive shares, allow a specific AD group rather than the broad Domain Users group.
Exercise
Which command verifies that the Linux server can resolve a domain user after joining AD?
Show answer
getent passwd username queries the configured identity sources, including winbind, and should return the domain user's mapped Linux entry.