Slow Windows logon: identify and change the domain controller
Identify the domain controller in use, list DCs and force the Active Directory site of a Windows machine.
A slow Windows logon is often caused by the client authenticating against a distant or overloaded domain controller (DC). This article shows how to identify the DC in use, list the DCs of a domain, and steer a machine towards a given Active Directory site.
Identify the current domain controller
nltest /dsgetdc:contoso.com
echo %LOGONSERVER%
gpresult /r
%LOGONSERVER% shows the DC that authenticated the current session, and gpresult /r shows which site and DC were used to apply policies.
List the domain controllers
NETDOM QUERY /D:contoso.com DC
NETDOM QUERY /D:contoso.com PDC
The first command lists all DCs of the domain, the second shows the PDC emulator.
Check the AD site of the machine
nltest /dsgetsite
The site is auto-detected and stored in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters in the DynamicSiteName value (for example Default-First-Site-Name).
Force the AD site
To bypass automatic detection, create a SiteName value (type REG_SZ, the name is case sensitive) in the same key, containing the name of the AD site to use:
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\ /v SiteName /t REG_SZ /d "Site-Name"
Restart the Netlogon service (or the machine) so the change is taken into account, then check again with nltest /dsgetsite.
DNS
The client should use DNS servers that belong to the domain, ideally the ones of the target site, for example 192.0.2.10 and 192.0.2.11 for contoso.com. Wrong or distant DNS servers lead to the selection of a distant DC.
References
- Switch domain controller (Technipages)
- NT admin commands (Rob van der Woude)
- Forcing a server's Active Directory site (Essential.Exchange)
Notes
- The original note used a DC name as the
SiteNamevalue; this value must be an AD site name, so a placeholder is used here. - Forcing a site is a workaround; fixing the subnet definitions in AD Sites and Services is the proper solution.