Series32 partsВиталий Лещенко

Windows Server for beginners

Windows Server for beginners

A series for those who want to understand how Windows Server and Active Directory work inside: what happens between pressing Ctrl+Alt+Del and the desktop appearing, how domain controllers agree with each other, what lies in the directory and how to read it.

The series has two principles.

First: for every component, not only why it is needed but how it works. Which objects appear in the directory, which packets go over the network, what breaks and why. That is why almost every part has command output, event logs and a walk-through of what they say.

Second: we do everything from PowerShell, not with the mouse. A command can be repeated, put into a script and run on twenty servers, shown in an article more precisely than any screenshot, and on Server Core there is simply no other way.

First the basics: installing the server, disks and network, how Active Directory is built. Then the domain: the first controller, LDAP and Kerberos from the inside, DNS, DHCP, the second controller and replication. Protocols already covered in the Networking for beginners series are not explained again: where they come up, there is a link and the gist in two sentences.

  1. Part 1

    Installing Windows Server from scratch

    The server is installed from the 180-day evaluation ISO, and the key choice in the installer is the installation option: Server Core, with no graphical shell, is recommended for domain controllers, DNS and file servers, and changing it later takes a reinstall. All the first setup is done from PowerShell: the name with Rename-Computer, a static address with New-NetIPAddress, time with w32tm, updates with the PSWindowsUpdate module and roles with Install-WindowsFeature.

  2. Part 2

    Setting up disks and network: diskpart, netsh and their PowerShell replacements

    Disks are partitioned with diskpart or the Storage module (Initialize-Disk, New-Partition, Format-Volume), and the network is configured with netsh or the NetTCPIP, DnsClient and NetSecurity modules. The cmdlets are more convenient: they pass objects down the pipeline instead of acting on a selected context. The old utilities remain for the recovery environment, where there is no Storage module, and for what never got a replacement: portproxy port forwarding, HTTP.sys certificate bindings outside IIS and the WinHTTP system proxy.

  3. Part 3

    How does Active Directory work?

    Active Directory is an LDAP directory where Kerberos handles authentication, controllers are found through DNS and replication runs between equal controllers. Logically it is a forest with a shared schema and configuration, which is also the security boundary, holding domains and OUs for group policy and delegation; physically it is the ntds.dit database and the SYSVOL folder on every controller. A client looks for a controller by SRV records, so it must use a DNS server that knows the domain's zone.

  4. Part 4

    Setting up the first domain controller

    Install the AD DS role, check the parameters with Test-ADDSForestInstallation and promote the server with a single Install-ADDSForest command that takes the domain name, functional level, DNS and the DSRM password. In a few minutes it creates ntds.dit with five partitions, SYSVOL, the DNS zones and the directory services, the local SAM database stops being used, and all five FSMO roles and the global catalog go to the first controller. After the reboot dcdiag checks it, and computers join the domain with Add-Computer.

  5. Part 5

    How is the LDAP directory built?

    The directory is a tree of objects named by DNs, with attributes whose syntax the schema defines, and every client works with it through nine LDAP operations, where reading is a search with a base, scope, filter and attribute list. ldp.exe and ADSI Edit show it raw: FILETIME instead of dates, userAccountControl as a number, a RootDSE that answers without a bind, and the service CN=System and CN=Configuration. The controller checks edits for syntax but not for meaning, and a schema mistake can't be undone.

  6. Part 6

    How does Kerberos work?

    The client proves to the KDC once that it knows the password, gets a TGT encrypted with the krbtgt key and then uses it to get service tickets without sending the password anywhere. A service ticket is encrypted with the key of the account the service's SPN is registered on, and the server checks it itself, without the controller, taking the user's groups from the PAC inside the ticket. If the SPN isn't found, the client silently falls back to NTLM, and clocks more than five minutes apart break authentication.

  7. Part 7

    How does DNS work in the domain?

    The domain zone lives in the directory rather than in a file: each name is a dnsNode object in the DomainDnsZones or ForestDnsZones partition, and the zone replicates along with Active Directory, with no zone transfers. Machines register their own records through dynamic updates signed with Kerberos (GSS-TSIG), and each record gets an owner — the account whose ticket signed the update. Other names are resolved through forwarders, conditional forwarders or stub zones, and scavenging removes stale dynamic records.

  8. Part 8

    Setting up DHCPv4 in the domain

    The DHCP Server role starts handing out addresses only after the server is authorized in the directory (Add-DhcpServerInDC); then you create a scope, options and reservations, with option 6 pointing to the controllers. So that a second server can update the DNS records registered on behalf of clients, updates go through a dedicated svc-dhcp-dns account in the DnsUpdateProxy group. Failover provides fault tolerance: two servers share one scope in Load Balance or Hot Standby mode.

  9. Part 9

    Setting up DHCPv6 in the domain

    On a Windows server you create a scope for a /64 prefix (Add-DhcpServerv6Scope) with DNS options; the server hands out addresses at random from the whole prefix and reserves them by DUID and IAID instead of MAC. Clients come to it only if the router raises the M or O flag in its Router Advertisement, and the gateway still comes from the router: DHCPv6 only adds to RA. There's no failover for IPv6 — two servers simply hold the same scope.

  10. Part 10

    How does replication between domain controllers work?

    Every controller accepts changes itself and sends its partners only the changed attributes: each change is stamped with a USN and the invocationID of the controller where it was born, and the up-to-dateness vector keeps the same change from arriving twice. A conflict is decided by the attribute version, then by the timestamp. The KCC builds the connections; within a site replication runs on notification after 15 seconds, between sites on the site link schedule, and repadmin /replsummary and /showrepl check it.

  11. Part 11

    What is a read-only domain controller?

    An RODC is a controller for a branch office: it issues Kerberos tickets, answers LDAP and works as a DNS server, but refers writes to a writable controller and replicates nothing outbound. By default it holds no password hashes: only accounts on the allowed list of the password replication policy (PRP) are cached, and everyone else is checked by a controller in the office. It encrypts TGTs with the key of its own krbtgt_ account, so a stolen RODC opens neither other sites nor someone else's privileges.

  12. Part 12

    How does time work in the domain?

    Time in a domain follows a hierarchy: members take it from controllers, controllers from the PDC emulator, and only the PDC emulator of the forest root domain syncs with an external source the administrator assigns (w32tm /config /manualpeerlist). Controllers sign their replies with MS-SNTP using the computer account's password, so a domain member won't take time from an outside NTP server. A clock skew of more than five minutes breaks Kerberos and replication.

  13. Part 13

    Managing Active Directory from PowerShell

    The ActiveDirectory module talks to a domain controller not over LDAP but through the ADWS service on port 9389, which runs an ordinary LDAP search itself. One object is found with -Identity (sAMAccountName, DN, GUID or SID), several with -Filter, which the module translates into an LDAP filter executed on the server. Attributes are listed in -Properties rather than taken with *, and scripts that write pin one controller with -Server.

  14. Part 14

    How do WinRM and PowerShell Remoting work?

    WinRM implements the WS-Management standard: the client sends SOAP requests POST /wsman to port 5985 or 5986, and PowerShell Remoting is a resource inside which the PSRP protocol carries serialized objects. In a domain authentication goes through Kerberos, and the body is encrypted with the session key even over HTTP; without Kerberos the client demands HTTPS or TrustedHosts. Objects come back from a session deserialized, without methods, and on the server each session lives in its own wsmprovhost.exe.

  15. Part 15

    Managing servers from a workstation

    RSAT is installed on the workstation as Features on Demand Rsat.* with Add-WindowsCapability, and its modules, snap-ins and utilities reach servers in different ways. ActiveDirectory talks to ADWS on 9389, CDXML modules such as DnsServer with -CimSession use CIM over WinRM, while their -ComputerName, Get-WinEvent and MMC snap-ins use RPC, for which some firewall rules on the server are disabled by default. A missing module is imported from a server with implicit remoting — the same mechanism PowerShell 7 uses to load modules that aren't compatible with it.

  16. Part 16

    Setting up SSH on Windows Server

    OpenSSH Server comes preinstalled in Windows Server 2025: you start it (Start-Service sshd, Set-Service sshd -StartupType Automatic) and add the Domain profile to the port 22 firewall rule, which is created for Private only. Administrators and members of the built-in OpenSSH Users group may sign in, and administrators' keys live in the shared C:\ProgramData\ssh\administrators_authorized_keys, accessible only to SYSTEM and Administrators. PowerShell becomes the shell through the DefaultShell registry value, Kerberos sign-in is enabled with GSSAPI, and PowerShell 7 can do Remoting over SSH with -HostName.

  17. Part 17

    What are FSMO roles?

    FSMO roles are five operations that only one owning controller performs in a multi-master directory, because a conflict in them is unacceptable: the Schema Master and the Domain Naming Master per forest, the PDC Emulator, the RID Master and the Infrastructure Master per domain. The owner is recorded in the fSMORoleOwner attribute and is changed with Move-ADDirectoryServerOperationMasterRole: by a transfer while the owner is alive, or with -Force when the owner won't come back — then the cmdlet seizes the role. After a seizure of the Schema, Domain Naming or RID Master the old owner doesn't return to the network: it is cleaned out of the directory and rebuilt.

  18. Part 18

    How to troubleshoot the domain

    Checks always go in one order: dcdiag /s:<controller> /e /q, then repadmin /replsummary and /showrepl, the controllers' logs through Invoke-Command, w32tm /monitor, and nltest on the client that complains. Most often the culprit is DNS, time, the secure channel, RPC or SYSVOL, and event 4740 on the PDC shows the source of lockouts; some dcdiag "failures" from a workstation are the firewall and differing utility versions rather than faults. A reboot doesn't cure lingering objects (event 1988), a USN rollback after reverting to a snapshot (2095 and Dsa Not Writable = 4), or a controller that hasn't replicated for longer than the 180-day tombstone lifetime (2042).

  19. Part 19

    Replacing and retiring domain controllers

    A domain controller isn't upgraded in place but replaced: a new one on Windows Server 2025 is promoted next to it (only a freshly installed controller gets the 32 KB page database), FSMO roles, DNS, DHCP and everything that reaches the old one by name move to it, and the old one is demoted with Uninstall-ADDSDomainController. If a controller died or was demoted with -ForceRemoval, its NTDS Settings, server object, computer account, connections and DNS records stay in the forest and are removed by metadata cleanup, with a snap-in or ntdsutil. Once no controllers of older versions are left, the domain and forest functional levels are raised, irreversibly.

  20. Part 20

    How to back up and restore Active Directory

    You back up the system state of at least two controllers through the NTDS VSS writer — with wbadmin start systemstatebackup or a schedule from the WindowsServerBackup module — and keep backups for less than the 180-day tombstone lifetime; repadmin /showbackup and event 2089 show how old the last backup is. Deleted objects come back from the AD Recycle Bin, a lost controller is restored from a backup in DSRM and catches up with the rest from its partners. If objects are deleted on all controllers, ntdsutil authoritative restore raises the versions of their attributes so that the restored copy wins in replication.

  21. Part 21

    How do multiple domains and forests work?

    Domains of one forest share the schema, the configuration, the global catalog and the Enterprise Admins group, and are linked by an automatic two-way transitive trust over which Kerberos travels with referral tickets. What a domain has of its own is users, Domain Admins, policies and a partition that replicates in full only to its controllers and to the global catalogs as a partial copy. The security boundary is the forest, not the domain: a controller of any domain can change the shared partitions and issue a ticket with the SID of the forest administrators. A second forest is needed when the other administration isn't trusted; a child domain is created with Install-ADDSDomain.

  22. Part 22

    How does trust between forests work?

    A trust between forests is created by hand: the trusting forest on the resource side accepts the identities of the trusted forest's users, and a forest trust extends to all domains of both forests. Each forest must find the other's controllers in DNS, with a conditional forwarder or a stub zone; a forest trust is created with the CreateTrustRelationship method of the .NET Forest class, because there is no New-ADTrust and netdom trust doesn't create forest trusts. What the other forest can do in ours is decided by SID filtering (full on a forest trust until the TREAT_AS_EXTERNAL bit is set), selective authentication and TGT delegation, which since the 2019 updates is blocked until explicitly allowed.

  23. Part 23

    Granting access across a trust in practice

    Users and global groups of the other forest go into a domain local group of your own domain, and permissions on the resource are granted to that group: global and universal groups don't accept foreign principals, and the built-in groups of domain controllers don't accept domain local groups. The group member is a foreignSecurityPrincipal object named after the SID, which the domain controller creates by itself. This is how you open a file share, a server's local administrators, RDP and SQL Server, and with selective authentication you also grant the Allowed to Authenticate right on the server's account.

  24. Part 24

    How does Group Policy work?

    A policy object lives in two places: the container with the version and the list of client-side extensions is in CN=Policies,CN=System of the directory, and the files gpt.ini, Registry.pol and GptTmpl.inf are in SYSVOL, and they replicate independently. A policy is linked to a site, domain or OU with the gPLink attribute, and the client applies policies along the LSDOU chain, where each next one overrides the previous one unless a link above is enforced; in the background every 90 minutes with an offset of up to 30, on controllers every 5. Read and Apply Group Policy permissions and WMI filters narrow the scope, and gpresult and GroupPolicy events in the System log show the result.

  25. Part 25

    Setting up an AD CS certification authority

    The setup is a two-tier hierarchy: a standalone root CA outside the domain that is powered on once a year, and an enterprise CA that issues working certificates from templates stored in the directory. The root is published to CN=Public Key Services, and every domain member starts trusting the chain. The autoenrollment policy (AEPolicy = 7) hands certificates to computers without an administrator, while domain controllers get a certificate from the Domain Controller template even without it — and LDAPS starts working on them. The main dangers are an expired CRL, which breaks revocation checking, published templates that take the name from the request (ESC1), and web enrollment over HTTP with NTLM (ESC8).

  26. Part 26

    How do NPS and RADIUS work?

    RADIUS is the protocol between network equipment and an authentication server: an access point, switch or VPN gateway sends an Access-Request over UDP 1812 and gets back an Access-Accept with attributes such as a VLAN, an Access-Reject, or an Access-Challenge with the next EAP step, and the packets are protected by a shared secret and the Message-Authenticator attribute. NPS is the RADIUS implementation in Windows Server: it accepts requests only from registered clients, checks credentials against the directory and decides by two ordered lists of policies, where the first match wins and a failed constraint means rejection. For Wi-Fi the proof travels as EAP inside RADIUS, and with PEAP or EAP-TLS the server must present a certificate that the client verifies.

  27. Part 27

    Setting up Wi-Fi with 802.1X

    The access point becomes a RADIUS client and keeps the port closed, passing only EAPOL, until NPS sends an Access-Accept with the key for the PMK and, if needed, a VLAN number. Domain machines get a profile through Group Policy with PEAP or EAP-TLS and authMode = machineOrUser: the computer connects before sign-in with its own account, the user after sign-in, and for that NPS needs policies for both Domain Computers and Domain Users. Validating the server certificate by root and name is mandatory, otherwise an evil-twin access point will collect passwords.

  28. Part 28

    Setting up a remote access VPN

    The IKEv2 tunnel is terminated by strongSwan at the network edge, and NPS checks the users: the client arrives in IKE_AUTH without AUTH, and the gateway with auth = eap-radius presents its own certificate and repacks EAP into RADIUS without knowing a single password. The method is EAP-MSCHAPv2 without PEAP: the exchange is already protected by the IKE SA, and NPS verifies the response through a domain controller over Netlogon in three request–response pairs. The MS-MPPE keys from the Access-Accept become the last AUTH, the client gets an address from the pool and the controllers as DNS servers, and on Windows the connection is created with Add-VpnConnection and its algorithms set with Set-VpnConnectionIPsecConfiguration.

  29. Part 29

    Joining Linux to the domain

    Install realmd, sssd and adcli and run realm join: realmd finds the controllers through SRV records, adcli creates the computer account LNX1$ and writes its keys to /etc/krb5.keytab, and from then on sssd does the work — it reads users and groups over LDAP with Kerberos, checks passwords, changes the machine password every 30 days and updates the machine's DNS record. Before joining, the machine needs its full name, DNS and time from the controllers. The UID is computed from the domain SID and the RID, logons are limited with realm permit, an LDAP filter or logon rights from GPO, and sudo is granted to a domain group with a file in /etc/sudoers.d/.

  30. Part 30

    How does Kerberos single sign-on work?

    The TGT obtained at sign-in is exchanged at the KDC for a ticket to a service's SPN, and the service checks it with its own key from the keytab — no password needed. Applications reach Kerberos through GSSAPI and SPNEGO, which is how SSH (gssapi-with-mic), the web with Negotiate, PostgreSQL and NFS work. A service needs SPNs in the directory and its key in a keytab it can read; a TGT reaches a server only with delegation, and the Windows client delegates it only to servers trusted for delegation.

  31. Part 31

    How does Entra Connect work?

    Entra Connect on a domain server takes users, groups and their attributes from Active Directory and creates synchronized copies of them in Entra ID that can only be edited in the domain; a delta cycle runs every 30 minutes. Objects are tied together by the sourceAnchor — the Base64 of mS-DS-ConsistencyGuid (by default) or of objectGUID, called immutableId in the cloud. The recommended sign-in method is password hash synchronization every two minutes, and the MSOL_… account with replication rights makes the sync server a tier 0 server.

  32. Part 32

    How are accounts matched, and where are the pitfalls?

    An object from the domain is linked to a cloud object either by a hard match — on the anchor, immutableId, which equals the Base64 of mS-DS-ConsistencyGuid or objectGUID — or by a soft match on the primary address in proxyAddresses or the UPN; if nothing matches, the cloud creates a second object and quarantines the duplicate address or UPN. Synchronization can't write the anchor or the password to protected accounts with adminCount = 1, and rights granted through AdminSDHolder as "descendants only" don't apply to those accounts themselves. Moving a user to an OU outside the sync scope deletes their cloud account along with mail and OneDrive.