Skip to content

Joining a domain

Exercise joining-a-domain-annex.pdf · PDF

Marta sits down at a Windows PC she has never used. There is no account called marta on it. She types her name and password, and she is in. A minute later she does the same on a Debian laptop. Same name, same password, two operating systems. What did those two machines do beforehand to make that possible?

Your domain controller dc1 is running, but right now the domain has exactly one computer in it: dc1 itself. A domain with no clients is like a festival with an entrance and no bars. This page connects the bars.

What you will learn

  • What joining a domain does: the computer gets its own account and starts trusting the DC
  • The three conditions of a join: DNS pointing to the DC, clocks in step, a Windows edition that can join
  • Create a domain user, join win11 and sign in as TRAMUNTANA\marta
  • Join a Debian desktop with realm and log in with the same account
  • Tell a domain account from a local account on a joined machine
  • Why "the join failed, so the password is wrong" is usually a DNS problem

What joining means

Remember the festival: you show your ID once at the entrance and get a wristband (a Kerberos ticket). But a wristband is only useful at bars that have signed up with the organisers. A bar that never registered does not know what a wristband is.

Joining a domain is that registration: the computer goes to the domain controller, a domain administrator vouches for it, and from then on the computer accepts the domain's users.

Two things happen during a join:

  • The DC creates a computer account for the PC in the directory, next to the user accounts. Its name is the PC's name with a $ at the end, such as WIN11$. Computers have passwords too; they manage them by themselves.
  • The PC stores the domain's name and from now on offers a second kind of login: accounts it does not have, checked by the DC.

That is why a join asks for a domain administrator's password: adding a computer to the company is an act of trust.

Careful: joining is not logging in

Joining is done once per computer, by an administrator. Logging in is done every day, by users. After the join, any domain user can log in on that PC.

Three conditions before you join

Condition Why How you check
The PC's DNS server is the DC The PC finds the controller by asking DNS for the domain's SRV records. The normal network DNS has never heard of tramuntana.internal nslookup for the SRV record answers dc1
Clocks agree Kerberos tickets carry times; more than 5 minutes apart and they are refused Compare date on dc1 with the Windows clock
The edition can join Windows 11 Home cannot join a domain; Pro, Enterprise and Education can Settings → System → About → Edition

The first one is the step that fails in real companies. If the PC cannot find the controller in DNS, nothing after it works, and the error message talks about everything except DNS.

A user to log in with

On dc1, create Marta in the domain:

sudo samba-tool user add marta --given-name=Marta --surname=Soler
sudo samba-tool user list

The tool asks for the password twice (the domain refuses anything shorter than 7 characters or too simple) and answers User 'marta' added successfully. The list shows marta, Administrator, Guest and krbtgt. That last one is the account of the Kerberos service itself: the one that signs every wristband.

Windows joins

1. Point the DNS at the controller

PowerShell as administrator:

Get-NetAdapter
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 192.168.122.20
nslookup -type=SRV _ldap._tcp.tramuntana.internal
nslookup debian.org
  • Get-NetAdapter tells you the adapter's name (usually Ethernet); use it in the second line.
  • The SRV answer must name dc1.tramuntana.internal and port 389: the same record you read on the server, now asked by the client.
  • debian.org still resolves, because the DC forwards what it does not know to 192.168.122.1.

2. Join

Win+R → sysdm.cpl → tab Computer Name → Change... → Member of: Domain → tramuntana.internal → OK. Windows asks for an account allowed to join computers: Administrator with the domain's password, not the local Windows administrator. A welcome message confirms it; restart when asked.

The same in one command

In Windows PowerShell 5.1 the join can also be done with Add-Computer -DomainName tramuntana.internal -Credential TRAMUNTANA\Administrator -Restart.

3. Sign in as Marta, and prove it

At the sign-in screen choose Other user and type TRAMUNTANA\marta. The first sign-in takes a while: Windows is building her profile. Then, in a terminal:

whoami
echo %LOGONSERVER%
klist
Command Output Meaning
whoami tramuntana\marta You are the domain user, not a local one
echo %LOGONSERVER% \\DC1 The DC that checked the password
klist Tickets, one for krbtgt/TRAMUNTANA.INTERNAL The wristband, on the client

Back on dc1, sudo samba-tool computer list used to print only DC1$. Now there is a second line: your Windows PC's name followed by $.

What happened at that login

flowchart LR
    W["<b>win11</b><br>Marta types her password"] -->|"1. DNS: who is the DC?<br>SRV records"| DNS["<b>DNS on dc1</b>"]
    W -->|"2. Kerberos: proof of password"| KDC["<b>KDC on dc1</b><br>gives a TGT"]
    W -->|"3. LDAP: who is marta,<br>which groups?"| LDAP["<b>Directory on dc1</b>"]
    W -->|"4. creates C:\Users\marta"| PROF["<b>Profile</b><br>on this PC"]

The account lives in the directory. The profile — her desktop, her documents — is created on each PC she uses. Her files are not on the server just because her account is.

Two kinds of account on one PC

Sign out and sign in with the local account you have used all year, typed as .\yourname. The .\ means "an account of this computer". Both work:

.\yourname (local account) TRAMUNTANA\marta (domain account)
Where the account lives In this PC's own list In the directory on dc1
Who checks the password This PC The DC (the KDC)
On which PCs it works Only this one Every PC joined to the domain

The same domain account can be written two ways: TRAMUNTANA\marta (NetBIOS style) and marta@tramuntana.internal, the user principal name (UPN), which looks like an e-mail address. Both work at the sign-in screen.

A laptop on a train

Pause dc1 and sign in as marta again: it still works. Windows keeps a protected copy of the last successful domain logons, so a laptop away from the office can still be used.

Linux joins too

An Active Directory domain is DNS + Kerberos + LDAP, and Linux speaks all three. Two pieces of software do the work:

  • realmd provides the realm command, which discovers and joins the domain.
  • SSSD (System Security Services Daemon) is a service that looks up users in the directory and checks their passwords with Kerberos, at every login.
Windows 11 Debian 13 (deb-lab)
Join tool System Properties (sysdm.cpl) or Add-Computer realm join (package realmd)
Who asks the DC at each login Built into Windows SSSD
A domain user is written TRAMUNTANA\marta marta@tramuntana.internal
Home folder C:\Users\marta /home/marta@tramuntana.internal, created at first login

1. DNS first, again

nmcli -t -f NAME con show --active
sudo nmcli con mod "Wired connection 1" ipv4.dns 192.168.122.20 ipv4.ignore-auto-dns yes
sudo nmcli con up "Wired connection 1"
getent hosts dc1.tramuntana.internal

The first command gives the connection's name; use yours in the next two. The last must answer 192.168.122.20 dc1.tramuntana.internal.

2. Discover and join

sudo apt install -y realmd sssd sssd-tools libnss-sss libpam-sss adcli
sudo realm -v discover tramuntana.internal
sudo realm join -v -U Administrator tramuntana.internal
sudo pam-auth-update --enable mkhomedir
realm list
  • discover finds the domain through DNS and reports its type (active-directory) and the software it needs.
  • join asks for the Administrator's password, creates the computer account and writes /etc/sssd/sssd.conf.
  • mkhomedir tells PAM to create a home folder the first time a domain user logs in.

3. Marta on Linux

getent passwd marta@tramuntana.internal
grep marta /etc/passwd
id marta@tramuntana.internal
su - marta@tramuntana.internal
pwd
exit

getent prints a line in the shape of /etc/passwd, but grep marta /etc/passwd finds nothing: the answer came from the directory, through SSSD. id shows a large user ID and the group domain users@tramuntana.internal. SSSD computes that ID from Marta's identifier in the directory, so it is the same on every Linux machine of the domain. On dc1, sudo samba-tool computer list now has a third line, DEB-LAB$.

When the join fails

Symptom Cause
"An Active Directory Domain Controller for the domain could not be contacted" DNS. Check the client's DNS server and that dc1 is running and answers ping 192.168.122.20
The join refuses the password You typed the local Windows administrator, not the domain's Administrator
The option Domain is greyed out Windows 11 Home
realm: No such realm found DNS on deb-lab, or dc1 is paused
su - marta@... says the user does not exist sudo systemctl restart sssd, then getent again

Key takeaways

  • Joining registers a computer in the domain: the DC creates a computer account ending in $, and the PC starts accepting domain users.
  • Before a join: the PC's DNS must be the DC, the clocks must agree within 5 minutes, and Windows must not be Home.
  • Join once per computer (an administrator); log in every day (any domain user).
  • On a joined PC, .\name is a local account and TRAMUNTANA\marta (or the UPN marta@tramuntana.internal) is a domain account.
  • Linux joins with realm join; SSSD looks up domain users and checks their passwords with Kerberos.
  • The account lives in the directory; the profile is created on each PC the user signs in to.

Quick check

1. A PC cannot join and says a domain controller could not be contacted. What do you check first?
  • That the PC's DNS server is the domain controller
  • That Marta's password is long enough
  • That the PC has enough free disk space
  • That the printer is shared on the network

The PC finds the controller by asking DNS for the domain's SRV records. If its DNS server is not the DC, nothing after that can work.

2. Which Windows 11 edition cannot join a domain?
  • Home
  • Pro
  • Enterprise
  • Education

Windows 11 Home cannot join a domain; Pro, Enterprise and Education can. Check it in Settings → System → About before planning a join.

3. What does the domain controller create when a computer joins?
  • A computer account whose name ends in $
  • A copy of every domain user on the PC
  • A new domain with the PC's name
  • A shared folder for the PC

The join adds a computer account to the directory, such as WIN11$ or DEB-LAB$. You can list them with samba-tool computer list.

4. On a joined PC, what does typing .\enric at the sign-in screen mean?
  • A local account of this PC
  • A domain user called enric
  • The administrator of the domain
  • A temporary guest account

.\ means "this computer". Local accounts keep working after the join; the PC checks their passwords itself, not the DC.

5. On Linux, which service looks up domain users and checks their passwords?
  • SSSD
  • CUPS
  • NFS
  • cron

SSSD asks the directory (LDAP) and Kerberos on behalf of Linux logins. That is why getent passwd marta@tramuntana.internal answers even though Marta is not in /etc/passwd.

6. Marta signs in on win11 with her domain account and saves a document on the desktop. Where is that document?
  • On win11, in her profile under C:\Users\marta
  • On dc1, next to her account in the directory
  • On every PC of the domain, synchronised
  • On ubu-srv, in the share common

The account lives in the directory; the profile and its files are created on each PC she uses. Her files only reach a server when you give her a share there.

7. A new laptop must join tramuntana.internal and its join keeps failing. Select the two checks that come first.
  • nslookup for the SRV record of the domain answers dc1
  • The laptop's clock and the DC's clock show the same minute
  • Marta has already signed in on the laptop once
  • The laptop has its own local account called marta

A join needs DNS pointing at the DC (so the SRV records answer) and clocks within 5 minutes (for Kerberos). Users sign in only after the join, and local accounts are irrelevant to it.

One user, three machines, one password. Next, the whole company goes into the directory, in order, by department — Domain users, groups and OUs.