Active Directory For Beginners
By Himanshu Shekhar | 07 Aug 2022 | (0 Reviews)
Suggest Improvement on Active Directory For Beginners — Click here
Module 00 : Active Directory Introduction & Architecture
This module provides a foundational understanding of Active Directory (AD), the directory service at the heart of most enterprise Windows environments. It covers what AD is, why it exists, how it evolved, its core components, the difference between logical and physical structure, and real-world use cases. Mastering these fundamentals is essential before diving into configuration, security, or advanced AD topics.
0.1 What is Active Directory?
🔍 Definition
Active Directory (AD) is a directory service developed by Microsoft for Windows domain networks. It stores information about objects on the network — such as users, groups, computers, printers, and applications — and makes this information easy for administrators and users to find and use.
AD authenticates and authorizes all users and computers in a Windows domain, enforcing security policies and allowing centralized management of resources. It is built on standard protocols including LDAP (Lightweight Directory Access Protocol), Kerberos for authentication, and DNS (Domain Name System) for service location.
Think of AD as a phonebook for your entire organization’s IT resources, plus a security guard that checks IDs before letting anyone access those resources.
🧠 Core Concepts
- Directory Service: A hierarchical database that stores objects and their attributes. Objects can be users (with fields like name, password, phone), computers, groups, or even policies.
- Authentication: Verifying the identity of a user or computer. AD primarily uses Kerberos (default) and can fall back to NTLM.
- Authorization: Determining what an authenticated user is allowed to do, based on group memberships and permissions.
- Policy Enforcement: Group Policy Objects (GPOs) allow administrators to define security settings, software installation, scripts, and desktop configurations across the domain.
- Centralized Management: Administrators can manage all objects from a single console (Active Directory Users and Computers) or via PowerShell.
📦 AD as a Database
The AD database is stored in a file called NTDS.DIT (NT Directory Services Directory Information Tree) on each domain controller.
It uses the Extensible Storage Engine (ESE) (also known as Jet Blue) to provide high-performance, transactional data storage.
The database is divided into partitions (also called naming contexts):
- Domain partition: Contains objects specific to a domain (users, groups, computers). Replicated to all DCs in that domain.
- Configuration partition: Stores forest-wide configuration information (site topology, service definitions). Replicated to all DCs in the forest.
- Schema partition: Defines all object classes and attributes that can be created in the forest. Replicated to all DCs.
- Application partitions: Optional partitions for application-specific data (e.g., DNS zones).
🌐 AD and DNS
Active Directory is tightly integrated with DNS. Domain controllers register SRV records in DNS so that clients can locate them. Without DNS, clients cannot find the domain, and many AD functions break.
0.2 Why Active Directory Exists
📉 The Pre-AD Era: Workgroups and NT Domains
Before Active Directory, small networks often used workgroups, where each computer maintained its own local user database. For larger environments, Microsoft introduced Windows NT domains (NT 3.1/3.5/4.0). In an NT domain, there was a single Primary Domain Controller (PDC) that held the master copy of the domain database, and one or more Backup Domain Controllers (BDCs) that held read-only copies. This model had several limitations:
- Single point of failure: If the PDC went down, changes could not be made (though authentication could still happen via BDCs).
- Flat structure: Domains could not be organized hierarchically; all users and computers were in one flat list.
- Replication was one-way: BDCs pulled changes from the PDC; there was no multi-master replication.
- Limited scalability: The domain database had a maximum size (around 40 MB) and number of objects (about 40,000).
- No delegation: Administrative permissions were all-or-nothing within a domain.
🚀 The Birth of Active Directory
Active Directory was introduced with Windows 2000 Server to overcome these limitations. It was designed from the ground up to be:
- Hierarchical and extensible: Domains can be organized in trees, and forests can contain multiple trees.
- Scalable: Supports millions of objects per domain and hundreds of domains per forest.
- Multi-master replication: Any domain controller can accept changes, which then replicate to others.
- Standards-based: Uses LDAP for directory access, Kerberos for authentication, and DNS for naming and location.
- Granular delegation: Administrators can delegate control over specific OUs or tasks.
- Integrated with Group Policy: Centralized configuration management.
🎯 Business Drivers
- Operational efficiency: IT staff can manage identities and policies from a central location, reducing manual work and errors.
- Security and compliance: Enforce strong authentication, password policies, and auditing across the organization.
- User experience: Single sign-on (SSO) means users log in once to access all permitted resources (file servers, printers, intranet, etc.).
- Cost reduction: Automating user provisioning and deprovisioning lowers administrative overhead and improves security (no orphaned accounts).
0.3 Evolution from Windows NT to AD DS
📜 Detailed Version History
| Windows Version | Key AD Innovations | Notable Features |
|---|---|---|
| Windows NT 4.0 (1996) | Domain model with PDC/BDC | Flat domain structure, single master replication, limited scalability, no LDAP support. |
| Windows 2000 Server (2000) | Active Directory debut | Multi-master replication, LDAP, Kerberos, hierarchical domains (trees/forests), OUs, Group Policy, AD schema, global catalog. |
| Windows Server 2003 | AD improvements | Cross-forest trusts, application partitions, replication enhancements (linked value replication), ADMT (migration tool), RODC introduced (but not fully implemented until 2008). |
| Windows Server 2008 / 2008 R2 | Major enhancements | Read-Only Domain Controller (RODC), fine-grained password policies (FGPP), Active Directory Recycle Bin, PowerShell cmdlets for AD, DFSR for SYSVOL replication. |
| Windows Server 2012 / 2012 R2 | Management and virtualization | Active Directory Administrative Center with GUI improvements, virtual domain controller cloning, Active Directory-based activation, and group managed service accounts (gMSA). |
| Windows Server 2016 | Security and hybrid | Privileged Access Management (PAM) using Microsoft Identity Manager, Azure AD integration, Credential Guard support, and Windows Defender for Identity integration. |
| Windows Server 2019 / 2022 | Enhanced security | Improved group managed service accounts, AD forest trusts with selective authentication, time service improvements, and support for TLS 1.3. |
🔧 Important Protocol Changes
- Kerberos adoption: Replaced NTLM as the default authentication protocol, providing mutual authentication and reduced risk of pass-the-hash attacks.
- DNS integration: AD requires DNS for domain controller location; dynamic DNS updates allow DCs to register SRV records automatically.
- LDAP over SSL (LDAPS): Introduced to encrypt directory queries, later replaced by LDAP over TLS (StartTLS).
0.4 AD Components Overview
Active Directory consists of both logical and physical components that work together to provide directory services.
🧩 Logical Components (The Design)
- Forest – The outermost container. A forest is a collection of one or more domains that share a common schema, configuration, and global catalog. Domains in a forest are linked by transitive trusts. The first domain created in a forest is called the forest root domain.
-
Domain – A logical grouping of objects (users, groups, computers) that share a common directory database and security policies. Domains are identified by DNS names (e.g.,
corp.example.com). Each domain has its own security boundaries; administrators of one domain do not automatically have rights in another domain unless trusts exist. -
Organizational Unit (OU) – Containers used to organize objects within a domain. OUs can be nested to reflect business structure (e.g., by department, location, or function). They are used to:
- Delegate administrative authority (e.g., helpdesk can reset passwords for the Sales OU).
- Apply Group Policies (GPOs) to a subset of users or computers.
- Hide objects from users (through security filtering).
-
Objects – The actual entities stored in AD. Common object classes include:
- User – represents a person or service account; attributes include logon name, password, phone, etc.
- Group – a collection of users, computers, or other groups used for assigning permissions.
- Computer – represents a workstation or server joined to the domain.
- Printer – represents a shared printer in the directory.
- Contact – an object with no security principal, used for email addresses.
- Shared Folder – points to a network share.
- Schema – Defines all object classes and attributes that can exist in the forest. The schema is extensible; applications can add their own classes and attributes (e.g., Exchange Server extends the schema to add mailbox attributes). Schema updates are forest-wide and should be performed carefully.
🖥️ Physical Components (The Infrastructure)
- Domain Controller (DC) – A server that hosts a writable copy of the AD database for its domain. It authenticates users, processes LDAP queries, and replicates changes to other DCs. Each DC also holds a copy of the schema and configuration partitions for the forest.
- Global Catalog Server (GC) – A DC that additionally holds a partial read-only copy of all objects in the forest (only some attributes, like name and location). GCs enable forest-wide searches and are essential for logon in a multi-domain environment (they provide universal group membership information).
- Read-Only Domain Controller (RODC) – A DC that holds a read-only copy of the AD database. Introduced in Windows Server 2008, RODCs are intended for branch offices with lower physical security. They cache user credentials only on demand and can be managed by delegated non-administrative users.
-
Sites & Subnets – Sites represent physical locations with good network connectivity (LAN speed). Subnets are IP ranges assigned to sites. AD uses site information to:
- Direct clients to the nearest domain controller.
- Optimize replication traffic between DCs (intra-site replication is frequent and uncompressed; inter-site replication can be scheduled and compressed).
0.5 AD Logical vs Physical Structure
Active Directory separates the logical representation of the organization from the physical network infrastructure. This separation allows administrators to design a directory that reflects business needs independently of network topology.
🧭 Logical Structure (Business View)
- Based on business hierarchy, geography, or administrative requirements.
- Examples: a company may have a single domain with OUs for each department (HR, Finance, IT) or separate domains for subsidiaries.
- Logical structure is defined by:
- Forests and domains – security boundaries.
- OUs – delegation and GPO boundaries.
- Groups – access control.
- Changes to logical structure (creating a new OU, moving users) do not directly impact network traffic.
🌍 Physical Structure (Network View)
- Based on actual network links, locations, and connectivity speed.
- Defined by sites (collections of well-connected subnets) and site links (connections between sites).
- Physical structure influences:
- Authentication: Clients find a DC in their own site first.
- Replication: DCs within a site replicate frequently (pull model); between sites, replication can be scheduled and compressed to save bandwidth.
📊 Comparison Table
| Aspect | Logical Structure | Physical Structure |
|---|---|---|
| Purpose | Organize and manage objects based on business hierarchy | Optimize network traffic and replication |
| Components | Forest, Domain, OU, Objects, Schema | Domain Controllers, Sites, Subnets, Replication links |
| Visibility | Visible to users and administrators (e.g., domain structure in logon screen) | Typically invisible to users; managed by admins in AD Sites and Services |
| Independence | Can be designed without regard to physical network (e.g., one domain for entire company) | Must reflect actual network links and locations to avoid poor performance |
| Example | A company has a single domain contoso.com with OUs for HR, IT, Sales, and Engineering |
Offices in New York, London, and Tokyo are separate sites with site links representing WAN connections |
🔄 Interaction Between Logical and Physical
When a user logs on, their computer is in a specific subnet, which is associated with an AD site. The logon request goes to a DC in that site (or a nearby site). The DC authenticates the user using the domain database (logical). Group Policies linked to the user's OU (logical) are applied, and the computer may receive policy settings. Meanwhile, DCs in different sites replicate changes according to the site link schedule (physical).
0.6 Real-World Enterprise Use Cases
Active Directory is used in organizations of all sizes. Here are typical enterprise scenarios with expanded details:
🏢 Case Study 1: Centralized User Authentication
Scenario: A multinational corporation with 50,000 employees uses AD to manage identities. Employees log into their Windows workstations using their domain credentials. They access file servers, internal websites, and email (Exchange) with the same password. When an employee leaves, IT disables the account once, and access to all resources is immediately revoked.
Technical details: AD stores user objects with attributes like sAMAccountName, userPrincipalName, displayName, and hashed credentials.
Authentication is handled via Kerberos: the client obtains a Ticket Granting Ticket (TGT) from the DC and then uses it to request service tickets for resources.
⚙️ Case Study 2: Group Policy Management
Scenario: A financial services firm needs to enforce strict security settings on all company workstations. They create a GPO linked to the domain that enforces password complexity (minimum length 12, complexity required), locks workstations after 15 minutes of inactivity, and disables USB storage devices. For IT staff, they create a separate GPO applied to the IT OU that allows PowerShell execution and local admin rights.
Technical details: GPOs are stored in two parts: Group Policy Template (GPT) in SYSVOL (scripts, policies) and Group Policy Container (GPC) in AD (version, path). When a computer starts, it downloads and applies GPOs in order: Local, Site, Domain, OU (with inheritance and blocking).
🔐 Case Study 3: Delegated Administration
Scenario: A university's IT department has a central team that manages the domain, but each faculty (e.g., Engineering, Arts) has its own support staff. The central team creates OUs for each faculty and delegates control: faculty support staff can reset passwords and manage group memberships only within their own OU. This prevents them from affecting other faculties or domain-wide settings.
Technical details: Delegation is achieved by modifying ACLs on OUs. The Delegation of Control Wizard assigns permissions like "Reset user passwords" or "Manage group membership" to specific security groups.
🌐 Case Study 4: Multi-Site Deployment
Scenario: A global retailer has headquarters in Chicago, distribution centers in Europe and Asia, and retail stores worldwide. They deploy domain controllers at each major site. They configure AD sites for each region (North America, Europe, Asia) with subnets assigned. Site links are created with appropriate costs (e.g., Chicago–Europe cost 100, Europe–Asia cost 200). Replication between sites is scheduled to occur during off-peak hours to conserve WAN bandwidth.
Technical details: The Knowledge Consistency Checker (KCC) automatically generates replication topology. Inter-site replication uses the Intersite Messaging Protocol (ISM) and can be compressed. Clients in a store in Paris are in the Europe site and authenticate to a local DC, not to Chicago.
☁️ Case Study 5: Hybrid Identity with Azure AD
Scenario: A medium-sized company uses Office 365 and wants users to have the same password for on-premises and cloud. They deploy Azure AD Connect to synchronize on-premises AD with Azure AD. Password hash synchronization (or pass-through authentication) allows users to sign into Office 365 with their corporate credentials. They also enable seamless SSO so that domain-joined computers automatically sign into Azure AD without prompting.
Technical details: Azure AD Connect uses the DirSync engine to replicate changes. It can also write back attributes (e.g., groups) from Azure AD to on-premises. Hybrid identity requires Azure AD Premium licenses for features like password writeback and device writeback.
📁 Case Study 6: Resource Access Control
Scenario: A law firm uses AD to control access to sensitive legal documents. They create security groups: "Legal_Attorneys", "Legal_Paralegals", "Finance_Team". NTFS permissions on shared folders are set to allow read/write only to the appropriate groups. When a new attorney joins, HR creates the user account in AD and adds it to the "Legal_Attorneys" group. The attorney immediately gains access to all resources.
Technical details: When a user accesses a file share, the server checks the user's access token (which includes group SIDs) against the ACL. Changes to group membership take effect after the user logs off and on again (or after Kerberos ticket renewal).
Active Directory is not just a user database; it’s the core of identity, access, and policy management in Windows environments. Understanding its architecture is the first step to mastering AD. The use cases above demonstrate how AD adapts to various organizational needs, from small businesses to global enterprises.
0.7 Active Directory Setup from Scratch (Windows Server)
Before performing Active Directory attacks or applying hardening techniques, it is essential to understand how an AD environment is built. This section provides a step-by-step guide to setting up Active Directory Domain Services (AD DS) using Windows Server.
This lab-based setup mirrors real enterprise environments and forms the foundation for learning AD misconfigurations, attacks, and defenses.
Follow this detailed external guide for screenshots and exact configuration steps:
👉 Active Directory Domain Services Setup (Windows Server)
🎓 Module 00 : Active Directory Introduction & Architecture Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 01 : Domain Controllers & Core Services
This module provides a comprehensive deep dive into Domain Controllers (DCs) – the servers that host Active Directory Domain Services (AD DS). You will learn what a DC is, how to install and promote a server to a DC, the role of the Global Catalog, the five FSMO (Flexible Single Master Operation) roles, and the purpose of Read-Only Domain Controllers (RODCs). Understanding these core components is essential for anyone managing or securing an Active Directory environment.
1.1 What is a Domain Controller (DC)?
🔍 Definition
A Domain Controller (DC) is a server that runs Active Directory Domain Services (AD DS).
It stores a writable copy of the Active Directory database (NTDS.DIT) for its domain,
authenticates users and computers, enforces security policies, and replicates directory changes
with other DCs in the domain and forest.
Think of a DC as the brain of the domain – it knows every user, every computer, and every security rule. It checks IDs (authentication) and decides who can go where (authorization).
🧠 Core Functions of a Domain Controller
- Authentication: Verifies user and computer logon credentials using Kerberos (default) or NTLM.
- Authorization: Provides access tokens that determine what resources a user can access.
- Directory storage: Hosts the AD database, which contains all objects (users, groups, computers) and their attributes.
- Replication: Synchronizes changes with other DCs to ensure consistency across the domain/forest.
- Group Policy processing: Stores and replicates Group Policy Objects (GPOs) and provides them to clients.
- DNS services: Often runs DNS to support AD location (SRV records) and name resolution.
🏛️ Domain Controller Architecture
A DC runs the following key components:
- NTDS.DIT: The database file storing directory data. It is divided into partitions (domain, configuration, schema).
- EDB.Log files: Transaction logs that ensure database integrity; changes are written first to logs, then to the database.
- SYSVOL: A shared folder that contains Group Policy templates and logon scripts, replicated among DCs (using FRS or DFS-R).
- LSASS (Local Security Authority Subsystem Service): Handles authentication and security policies.
- KDC (Key Distribution Center): Implements the Kerberos protocol, issuing tickets.
📊 Domain Controller Placement Considerations
In an enterprise, DCs should be placed strategically:
- At least two DCs per domain: Provides redundancy and fault tolerance.
- At each major site: Users authenticate locally to avoid WAN latency.
- Global Catalog servers: At least one per site for multi-domain forests.
- Secure physical location: DCs hold the keys to the kingdom; physical security is paramount.
1.2 Installing AD DS Role
📦 Prerequisites
Before installing AD DS, ensure the following:
- Windows Server edition: Standard, Datacenter, or Essentials (not Core? Core can be used, but GUI is optional).
- Static IP address: DCs must have a static IP to avoid DNS registration issues.
- DNS configuration: The server must point to itself (or another DC) for DNS if it will host DNS.
- NTFS volume: The database, logs, and SYSVOL must be on NTFS partitions.
- Administrator credentials: You need local admin rights on the server.
- Time synchronization: Accurate time is critical for Kerberos.
- Network connectivity: To other DCs (if adding to existing domain).
🛠️ Installation Steps (Server Manager GUI)
- Open Server Manager → Add roles and features.
- Select installation type: Role-based or feature-based installation.
- Select the target server.
- In the Server Roles list, check Active Directory Domain Services.
- Add required features when prompted (e.g., .NET Framework, Group Policy Management tools).
- Proceed through the wizard and click Install.
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
After installation, the server is not yet a domain controller – it's just a server with the AD DS binaries. You must promote it to a DC (next section).
1.3 Promoting Server to DC
🆙 What is Promotion?
Promotion is the process of configuring a server with the AD DS role to become a domain controller. During promotion, you either create a new domain (forest) or add the server to an existing domain as an additional DC.
🚀 Promotion Methods
- Server Manager (post-install): A notification flag appears; click "Promote this server to a domain controller".
- Active Directory Domain Services Configuration Wizard: Launched from Server Manager or via
dcpromo.exe(older). - PowerShell: Using
Install-ADDSDomainControllerorInstall-ADDSForestcmdlets. - Unattended installation: Using answer files (for large deployments).
📝 Promotion Steps (GUI)
- Deployment Configuration: Choose:
- Add a domain controller to an existing domain: For additional DC.
- Add a new domain to an existing forest: For a new child domain or tree.
- Add a new forest: For the first DC in a new forest.
- Domain Controller Options:
- Select Domain Name System (DNS) server (usually checked).
- Select Global Catalog (GC) (recommended for most DCs).
- Set Directory Services Restore Mode (DSRM) password – this is a local administrator password for recovery mode.
- DNS Options: If DNS is not delegated, you may see a warning – it's fine.
- Additional Options: For existing domain, you can specify a source DC for replication.
- Paths: Specify locations for database, log files, and SYSVOL (defaults under
C:\Windows\NTDSandC:\Windows\SYSVOL). - Review Options: Verify settings and click Next.
- Prerequisites Check: The wizard runs a series of tests (e.g., DNS resolution, connectivity). Fix any errors.
- Install: Click Install. The server will reboot automatically.
⚙️ PowerShell Promotion Example
To add a DC to an existing domain:
Install-ADDSDomainController -DomainName "contoso.com" -Credential (Get-Credential "CONTOSO\Administrator") -InstallDns:$true -GlobalCatalog:$true -SafeModeAdministratorPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) -DatabasePath "C:\Windows\NTDS" -LogPath "C:\Windows\NTDS" -SysvolPath "C:\Windows\SYSVOL"
1.4 Global Catalog Explained
🌐 Definition
The Global Catalog (GC) is a distributed data repository that contains a partial, read-only copy of all objects from every domain in the forest. It is stored on domain controllers that are designated as Global Catalog servers.
🔍 What is Stored in the GC?
- Every object in the forest, but only a subset of attributes (those most commonly used in searches, e.g., name, UPN, email, group memberships).
- Universal group memberships (essential for authentication across domains).
- The schema and configuration partitions are also present (but the GC refers to the partial replica of domain objects).
🎯 Purpose of the Global Catalog
- Forest-wide searches: Users can find objects (e.g., printers, users) across all domains.
- Authentication in multi-domain environments: When a user logs on, the GC provides universal group membership information, which is necessary to generate the user's access token.
- Exchange address book: Microsoft Exchange uses the GC to build the Global Address List (GAL).
📈 GC Placement Best Practices
- At least one GC per site: Especially in multi-domain forests, to avoid authentication referrals across WAN.
- Preferably all DCs as GCs: In small to medium forests (less than 100,000 objects), it's common to make every DC a GC. This simplifies design and ensures fast lookups.
- Consider replication load: GCs receive updates from all domains, so they have higher replication traffic. In very large forests, you may limit GCs to major sites.
⚙️ Enabling Global Catalog
During DC promotion, you can check the "Global Catalog" box. After promotion, you can change it in Active Directory Sites and Services:
- Expand the site → Servers → select the DC.
- Right-click NTDS Settings → Properties.
- Check Global Catalog.
1.5 FSMO Roles (5 Master Roles)
🔑 What are FSMO Roles?
Active Directory uses a multi-master replication model, meaning any DC can accept changes. However, certain operations are too sensitive to be performed by multiple DCs simultaneously. For these, Flexible Single Master Operation (FSMO) roles designate a single DC as the authoritative master for that operation. There are five FSMO roles, divided into forest-wide and domain-wide roles.
🌲 Forest-Wide FSMO Roles
These roles exist once per forest.
- Schema Master: Controls all updates and modifications to the Active Directory schema. Schema changes (e.g., adding new attributes for Exchange) must be performed on the Schema Master. If this role is unavailable, you cannot extend the schema.
- Domain Naming Master: Manages the addition and removal of domains in the forest. It ensures that domain names are unique and that no duplicate names are created. It also handles cross-domain references.
🏛️ Domain-Wide FSMO Roles
These roles exist once per domain.
- Relative ID (RID) Master: Allocates sequences of relative IDs (RIDs) to each domain controller. When a new security principal (user, group, computer) is created, the DC assigns a SID comprising the domain SID and a RID. The RID Master ensures that RID pools do not overlap between DCs.
-
PDC Emulator: Acts as a Windows NT 4.0 Primary Domain Controller for backward compatibility.
It handles:
- Password changes (urgent replication of password changes to the PDC Emulator).
- Group Policy updates (default target for GPO edits).
- Time synchronization (all domain members sync time with the PDC Emulator of the domain).
- Domain-wide account lockout processing.
- Infrastructure Master: Updates cross-domain object references (e.g., when a user in one domain is added to a group in another domain). It compares its data with the Global Catalog and fixes stale references. The Infrastructure Master should not be on a Global Catalog server unless all DCs are GCs (in a single-domain forest, it's fine on a GC).
🔁 FSMO Role Placement Best Practices
- Schema Master and Domain Naming Master: Place on the same DC (typically the forest root domain controller) because they are forest-wide and changed infrequently.
- PDC Emulator: Place on a well-connected, high-performance DC; it handles the most real-time requests.
- RID Master: Can be on any DC, but ensure it's available to allocate RID pools.
- Infrastructure Master: In a multi-domain forest, place it on a DC that is not a Global Catalog (to avoid having up-to-date data already). In a single-domain forest, it can be on any DC.
🛠️ Transferring and Seizing FSMO Roles
If you need to move a role to another DC (e.g., for maintenance), you can transfer it gracefully. If the current role holder is permanently offline, you must seize the role (which is a more drastic operation).
Using GUI (Active Directory Users and Computers / Domains and Trusts / Schema snap-in):
- Right-click the domain or object → Operations Masters → select the appropriate tab → Change.
Using PowerShell:
Move PDC Emulator role to DC2
Move-ADDirectoryServerOperationMasterRole -Identity "DC2" -OperationMasterRole PDCEmulator
Seize roles (if current holder is dead) – use -Force
Move-ADDirectoryServerOperationMasterRole -Identity "DC2" -OperationMasterRole SchemaMaster, DomainNamingMaster -Force
1.6 Read-Only Domain Controller (RODC)
🔍 Definition
A Read-Only Domain Controller (RODC) is a type of domain controller introduced in Windows Server 2008. It hosts a read-only copy of the Active Directory database for its domain. Unlike a writable DC, changes cannot be made directly on an RODC; they must be replicated from a writable DC.
🏢 When to Use an RODC
- Branch offices with poor physical security: RODCs can be placed in locations where the server could be stolen or compromised, without exposing writable credentials.
- Sites with limited IT staff: RODCs can be managed locally by non-administrative users (delegated administration).
- Locations with slow WAN links: Users can authenticate locally, but writes (password changes) are forwarded to a writable DC.
🔐 Security Features of RODC
- Credential caching: By default, RODCs do not store user passwords. They can be configured to cache passwords for specific users (e.g., branch office employees) for faster authentication, but administrative accounts are never cached.
- Read-only database: Even if an attacker gains physical access, they cannot modify AD data.
- Administrative role separation: A local user (e.g., branch office manager) can be granted rights to manage the RODC (like updating drivers) without any domain admin privileges.
- Replication filtering: You can filter which attributes replicate to the RODC (e.g., confidential attributes).
📉 Limitations of RODC
- Cannot perform schema updates, domain upgrades, or any write operations.
- Cannot be a Global Catalog? Actually, RODC can be a Global Catalog, but it will still be read-only.
- Cannot host FSMO roles (except possibly PDC emulator? No, all FSMO roles require writable DCs).
- Applications that require write access to AD (e.g., Exchange) cannot use RODC as a primary DC.
🛠️ Deploying an RODC
Prerequisites:
- Forest functional level must be at least Windows Server 2003.
- A writable DC must be available in the domain.
- You must pre-stage the RODC computer account (optional but recommended).
Promotion steps (similar to writable DC) but with an extra option:
- Install AD DS role as usual.
- During promotion, choose Add a domain controller to an existing domain.
- In Domain Controller Options, check Read-only domain controller (RODC).
- You can also specify a Delegated administrator account for the RODC (a local user who can manage the server).
- Optionally, configure Password Replication Policy to specify which accounts can have their passwords cached on the RODC.
PowerShell example:
Install-ADDSDomainController -DomainName "contoso.com"
-ReadOnlyReplica -SiteName "BranchOffice-Site"
-AllowPasswordReplicationAccountName "BRANCH\AllowedUsers" `
-Credential (Get-Credential "CONTOSO\Administrator")
🔑 Password Replication Policy (PRP)
The PRP controls which user and computer accounts can have their passwords cached on the RODC. It consists of two lists:
- Allowed list: Accounts whose passwords may be cached (e.g., branch office users).
- Denied list: Accounts that must never be cached (e.g., domain admins).
By default, no accounts are allowed. You must explicitly add users/groups to the allowed list. Administrative groups (Domain Admins, Enterprise Admins, etc.) are automatically in the denied list.
🎓 Module 01 : Domain Controllers & Core Services Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 02 : Forest, Domain, OU – Active Directory Logical Structure
This module provides a deep dive into the logical structure of Active Directory, including forests, domains, Organizational Units (OUs), and trust relationships. Understanding these components is essential for designing, implementing, and managing an AD environment that meets business, security, and operational requirements. We will explore the purpose of each component, how they interact, and best practices for enterprise design.
2.1 What is a Forest?
🔍 Definition
A forest is the topmost logical container in an Active Directory hierarchy. It is a collection of one or more domains that share a common schema, configuration partition, and global catalog. The forest defines the security boundary for Active Directory; all domains within a forest trust each other transitively by default, and administrative permissions do not cross the forest boundary unless explicitly established through trusts.
Think of a forest as a company's entire directory ecosystem. All trees and domains inside belong to the same organization and share the same "rules" (schema).
🧩 Components of a Forest
- Forest Root Domain: The first domain created in a forest. It holds the Schema and Configuration partitions and cannot be removed. All other domains are children or trees under this root (or joined via trusts).
- Schema Partition: Defines all object classes and attributes that can exist anywhere in the forest. Extending the schema (e.g., for Exchange) affects all domains.
- Configuration Partition: Stores forest-wide configuration data such as site topology, service definitions, and display specifiers.
- Global Catalog (GC): A partial replica of all objects in the forest, stored on designated domain controllers. It enables searches across domains and is essential for user logon in multi-domain environments (provides universal group membership).
🌲 Forest Functional Levels
Forest functional levels determine which advanced AD features are available across the entire forest. Raising the functional level requires all domain controllers to be running a minimum Windows Server version.
| Forest Functional Level | Minimum DC OS | Key Features Enabled |
|---|---|---|
| Windows Server 2008 | 2008 | DFS-R support for SYSVOL, Advanced encryption types for Kerberos |
| Windows Server 2008 R2 | 2008 R2 | Active Directory Recycle Bin |
| Windows Server 2012 | 2012 | Virtual DC cloning, Group Managed Service Accounts (gMSA) |
| Windows Server 2012 R2 | 2012 R2 | Improvements to DC cloning, Authentication Policies and Silos |
| Windows Server 2016 | 2016 | Privileged Access Management (PAM), Azure AD join support |
🛠️ How to Create a New Forest (Step-by-Step)
A company is setting up Active Directory for the first time. We will create a brand-new forest and root domain.
✅ Prerequisites
- Windows Server installed (2016/2019/2022 recommended)
- Static IP address configured
- Administrator privileges
- Server renamed properly (e.g., DC01)
🔹 Step 1: Install Active Directory Domain Services Role
- Open Server Manager
- Click Manage → Add Roles and Features
- Select Role-based or feature-based installation
- Select your server
- Check Active Directory Domain Services (AD DS)
- Click Next → Install
🔹 Step 2: Promote Server to Domain Controller
- After installation, click "Promote this server to a domain controller"
- Select Add a new forest
- Enter Root Domain Name (Example: company.local)
- Select Forest Functional Level (Recommended: Windows Server 2016 or above)
- Set DSRM password
- Click Next → Install
- First Domain Controller
- Forest Root Domain
- Global Catalog Server
🔎 Verify Forest Creation
- Open Active Directory Users and Computers
- Open Active Directory Domains and Trusts
- Open Active Directory Sites and Services
- Run command:
echo %logonserver%
🗑️ How to Delete a Forest (Step-by-Step)
🔹 Step 1: Transfer or Seize FSMO Roles
- If multiple DCs exist, transfer FSMO roles to another DC
- If this is the only DC, roles will be removed automatically
🔹 Step 2: Demote the Domain Controller
- Open Server Manager
- Click Manage → Remove Roles and Features
- Uncheck Active Directory Domain Services
- Click Demote this domain controller
- Select:
- "Last domain controller in the domain"
- "Remove this domain"
- Set new local Administrator password
- Click Next → Remove → Reboot
- Active Directory is completely removed
- The forest no longer exists
- Server becomes standalone workgroup server
🔧 Cleanup (If Required)
- Manually clean DNS records
- Remove leftover metadata using
ntdsutil(if DC crashed)
🌍 When to Use Multiple Forests
Although a single forest is sufficient for most organizations, multiple forests may be required for:
- Administrative isolation: Different business units that should not trust each other by default.
- Schema independence: Applications that require incompatible schema extensions.
- Mergers and acquisitions: Before consolidating directories.
- Test/development environments: Isolated forests for testing schema changes or upgrades.
🏢 Real-World Working Example – Creating a Production Active Directory Domain
ABC Technologies Pvt Ltd is deploying a secure, scalable Active Directory Domain Services (AD DS) infrastructure for 150+ employees across two office locations in India. This deployment follows Microsoft production best practices.
🌐 Step 1: Domain Naming Strategy (Enterprise Best Practice)
- Public Website: abctech.com
- Internal Active Directory Domain: corp.abctech.com
- NetBIOS Name: CORP
Avoid using .local domains. Use a subdomain of your publicly registered domain for hybrid compatibility (Azure, SSO, SSL).
🖥️ Step 2: Infrastructure & Server Planning
- Domain Controllers: Minimum 2 (High Availability)
- Primary DC: DC01 – 192.168.10.10
- Secondary DC: DC02 – 192.168.10.11
- Operating System: Windows Server 2016/2019/2022
- Forest Functional Level: Windows Server 2016
- DNS: AD-Integrated DNS
🏗️ Step 3: Active Directory Forest & Domain Design
- Forest Model: Single Forest (Recommended)
- Domain Model: Single Domain (corp.abctech.com)
- Site Topology: HeadOffice + BranchOffice
- Global Catalog: Enabled on both DCs
📁 Organizational Unit (OU) Structure – Enterprise Standard
- Users
- Computers
- Servers
- Domain Controllers
- Service Accounts
- Groups
- HR
- IT
- Finance
- Forest Name: corp.abctech.com
- Forest Root Domain: corp.abctech.com
- Schema Master: DC01
- Domain Naming Master: DC01
- Global Catalog: Enabled
🔧 Step 4: Install Active Directory Domain Services (AD DS)
- Configure static IP address
- Rename server to DC01
- Install Windows Updates
- Open Server Manager → Add Roles and Features
- Select Active Directory Domain Services
- Install DNS Server role
- Promote server → Add New Forest
- Enter domain: corp.abctech.com
- Set DSRM password
- Complete installation and reboot
🔐 Step 5: Security Hardening & Administrative Model
- Create separate Domain Admin account
- Disable built-in Administrator (rename it)
- Implement Tiered Administration Model (Tier 0, 1, 2)
- Enable Advanced Audit Policies
- Disable SMBv1
- Enable LDAP Signing
📜 Step 6: Group Policy Configuration (Baseline Security)
- Password Policy (Complexity + 90 Days Expiry)
- Account Lockout Policy
- Windows Defender Policy
- Firewall Policy
- USB Restriction Policy
- Windows Update Policy
🌍 Step 7: DNS & Network Configuration
- Configure DNS Forwarders (ISP or 8.8.8.8)
- Verify SRV Records
- Check _msdcs zone replication
🔄 Step 8: Add Secondary Domain Controller (High Availability)
- Install AD DS on DC02
- Select "Add Domain Controller to Existing Domain"
- Enable Global Catalog
- Verify replication using
repadmin /replsummary
💾 Step 9: Backup & Disaster Recovery Planning
- Install Windows Server Backup
- Schedule Daily System State Backup
- Test Restore Procedure in Lab
- Document DSRM password securely
📊 Step 10: Validation & Health Checks
- Run
dcdiag - Run
repadmin /showrepl - Verify Event Viewer logs
- Test Domain Join from Client Machine
- Test User Login Authentication
The Active Directory Forest is now secure, redundant, scalable, and ready for enterprise operations.
2.2 What is a Domain?
🔍 Definition
A domain is a logical grouping of network objects (users, groups, computers, printers)
that share a common directory database and security policies. Domains are identified by a DNS name
(e.g., corp.contoso.com) and serve as an administrative boundary.
🔒 Domain as a Security Boundary
Domain administrators have full control over objects within their domain, but not over objects in other domains (unless trusts exist). Key security aspects:
- Authentication boundary: Users authenticate to domain controllers in their own domain.
- Policy boundary: Group Policies can be linked at the domain level, affecting all objects in the domain.
- Administrative isolation: Domain Admins group grants full rights only within that domain.
🗂️ Domain Database (NTDS.DIT)
Each domain has its own copy of the domain partition stored in NTDS.DIT on every domain controller in that domain.
This database contains all objects for that domain. The schema and configuration partitions are shared forest-wide.
📈 Domain Functional Levels
Domain functional levels enable features specific to that domain. Raising the level requires all DCs in the domain to run a minimum OS version.
| Domain Functional Level | Minimum DC OS | Key Features Enabled |
|---|---|---|
| Windows Server 2008 | 2008 | DFS-R, Advanced Kerberos, Last Interactive Logon Information |
| Windows Server 2008 R2 | 2008 R2 | Authentication Mechanism Assurance, Managed Service Accounts |
| Windows Server 2012 | 2012 | Group Managed Service Accounts, Fine‑grained password policy for all users |
| Windows Server 2016 | 2016 | Azure AD Join support, new claims and compound authentication |
🔗 Domain Naming and DNS
Every domain must have a valid DNS name. AD integrates with DNS in the following ways:
- Domain controllers register SRV records in DNS so clients can locate them.
- Clients use DNS to find a domain controller for their domain.
- DNS zones can be stored in AD (Active Directory-integrated zones) for secure, multi-master replication.
2.3 Organizational Units (OU)
🔍 Definition
An Organizational Unit (OU) is a container object within a domain used to organize other objects (users, groups, computers, and even other OUs). OUs provide a way to structure the directory hierarchically, mirroring business or operational divisions.
🎯 Purposes of OUs
- Delegation of administration: Grant non-administrative users control over objects within an OU (e.g., helpdesk resetting passwords for a specific department).
- Group Policy application: Link GPOs to OUs to apply settings to only the users/computers in that OU.
- Hiding objects: By setting permissions, you can hide OUs from certain users.
- Organizational clarity: Reflect the company structure (e.g., HR, IT, Sales) for easier management.
🧩 OU Hierarchy and Nesting
OUs can be nested to create a hierarchy. For example:
Company (domain)
├── HQ
│ ├── Users
│ │ ├── Executives
│ │ ├── IT
│ │ └── Sales
│ └── Computers
│ ├── Workstations
│ └── Servers
└── Branch Offices
├── NewYork
└── London
GPOs applied at a higher level are inherited by child OUs (unless blocked). This allows for tiered policy application.
🏛️ Default OUs
When you create a new domain, several default containers and OUs are created:
- Domain Controllers OU: Contains all domain controller computer objects. Default GPOs are linked here.
- Users container: Legacy container for users (not an OU, cannot link GPOs). Best practice is to create custom OUs for users.
- Computers container: Legacy container for computers (not an OU). Domain-joined computers appear here until moved.
- Builtin container: Holds default local groups (e.g., Administrators, Users).
📐 Designing an OU Structure
Best practices for OU design:
- Keep it simple: Reflect the business, not every possible detail.
- Plan for delegation: Create OUs where administrative responsibility will be delegated.
- Plan for Group Policy: Structure OUs so that GPOs can be applied at the appropriate level (e.g., separate OUs for users and computers).
- Avoid deep nesting: Too many levels can complicate permission and policy troubleshooting.
- Use a pilot OU: For testing GPOs before wide deployment.
🛠️ How to Create and Delete Organizational Units (Step-by-Step Guide)
✅ Method 1: Create OU Using Active Directory Users and Computers (GUI)
- Open Active Directory Users and Computers (ADUC)
- Expand your domain (corp.abctech.com)
- Right-click the domain → Select New → Organizational Unit
- Enter OU Name (Example: IT, HR, Sales)
- Check: Protect container from accidental deletion
- Click OK
⚡ Method 2: Create OU Using PowerShell (Enterprise Method)
New-ADOrganizationalUnit -Name "IT" -Path "DC=corp,DC=abctech,DC=com"
PowerShell method is recommended for automation and large enterprise deployments.
🏗️ Real-World OU Structure Example (Production)
corp.abctech.com
│
├── Tier-0
│ ├── Domain Controllers
│ └── Admin Accounts
│
├── Tier-1
│ ├── Servers
│ └── Service Accounts
│
├── Tier-2
│ ├── Users
│ ├── Workstations
│ ├── HR
│ ├── IT
│ └── Finance
🔐 Delegating Control on an OU (Step-by-Step)
- Right-click OU → Select Delegate Control
- Add Helpdesk group
- Select task (Reset Password, Create Users, etc.)
- Complete wizard
Delegation allows least privilege access and improves security compliance.
📜 Linking Group Policy to an OU
- Open Group Policy Management Console (GPMC)
- Right-click OU → Link an Existing GPO
- Select GPO (e.g., Password Policy, USB Restriction)
- Confirm and test policy application
🗑️ How to Delete an Organizational Unit
Step 1: Remove Protection from Accidental Deletion
- Right-click OU → Properties
- Go to Object tab
- Uncheck Protect object from accidental deletion
Step 2: Delete the OU
- Right-click OU
- Select Delete
- Confirm deletion
PowerShell Deletion Method
Remove-ADOrganizationalUnit -Identity "OU=IT,DC=corp,DC=abctech,DC=com"
📊 Best Practices for Enterprise OU Management
- Separate Users and Computers OUs
- Use Tiered Administrative Model
- Keep nesting levels minimal (3–4 levels max)
- Enable Active Directory Recycle Bin
- Document OU structure for audits
- Use naming standards (OU-HR, OU-IT, OU-Servers)
2.4 Tree vs Forest Trusts in Active Directory
🌲 What is a Domain Tree?
A Domain Tree is a collection of domains within the same Active Directory forest
that share a contiguous DNS namespace. For example:
contoso.com and asia.contoso.com.
- Automatically created parent-child trust
- Two-way trust by default
- Transitive across all domains in the tree
- Same forest security boundary
🌍 What is a Forest Trust?
A Forest Trust is a trust relationship between two separate Active Directory forests. It allows authentication and resource access between forests.
- Created manually by administrators
- Can be One-way or Two-way
- Transitive across all domains in both forests
- Used in mergers, acquisitions, partnerships
🔍 Types of Active Directory Trusts
- Parent-Child Trust – Automatic within forest
- Tree-Root Trust – Automatic between trees in same forest
- Forest Trust – Between separate forests
- External Trust – Between domain and external domain (non-transitive)
- Shortcut Trust – Improves authentication performance between distant domains
🔄 Trust Direction Explained
| Trust Type | Meaning |
|---|---|
| One-Way Trust | Trusted domain users can access resources in trusting domain |
| Two-Way Trust | Both domains can access each other's resources |
🔐 Authentication Types in Forest Trust
- Forest-Wide Authentication – All users authenticated automatically
- Selective Authentication – Admin must explicitly allow access per resource
📊 Comparison: Tree Trust vs Forest Trust
| Feature | Tree Trust | Forest Trust |
|---|---|---|
| Scope | Within same forest | Between two forests |
| Namespace | Contiguous DNS | Any DNS namespace |
| Creation | Automatic | Manual |
| Transitivity | Transitive | Transitive across forests |
| Direction | Two-way default | One-way or Two-way |
🛠️ How to Create a Forest Trust (Step-by-Step)
- Open Active Directory Domains and Trusts
- Right-click domain → Properties
- Go to Trusts tab
- Click New Trust
- Enter DNS name of other forest
- Select Forest Trust
- Select trust direction (One-way or Two-way)
- Choose authentication type
- Complete the wizard
⚡ Create Forest Trust Using PowerShell
New-ADTrust -Name "xyzcorp.com" `
-SourceForest "abctech.com" `
-TargetForest "xyzcorp.com" `
-TrustType Forest `
-Direction Bidirectional
🔍 Verify Trust Relationship
nltest /domain_trusts
Get-ADTrust -Filter *
🏢 Real-World Enterprise Use Cases
- Mergers & Acquisitions
- Partner company collaboration
- Resource Forest Model
- Multi-national enterprise structure
🔐 Security Best Practices for Active Directory Trusts
- Use Selective Authentication when possible
- Monitor trust relationships regularly
- Limit Domain Admin access across forests
- Enable auditing for cross-forest logons
- Document trust agreements formally
2.5 Trust Relationships Explained (Active Directory Deep Guide)
🔗 What is a Trust in Active Directory?
A trust relationship is a logical authentication link between two domains or forests that allows users in one domain to access resources in another domain. Trusts enable cross-domain authentication using Kerberos and NTLM protocols.
🧩 Complete Types of Trusts in Active Directory
- Parent-Child Trust – Automatic, two-way, transitive (within same forest)
- Tree-Root Trust – Automatic between tree root domains
- Shortcut Trust – Manual trust to optimize authentication path
- External Trust – Between domains in separate forests (non-transitive)
- Forest Trust – Between two forest root domains (transitive)
- Realm Trust – Between Active Directory and non-Windows Kerberos realm
🔄 Trust Direction (Incoming vs Outgoing)
| Trust Type | Meaning |
|---|---|
| Incoming Trust | Other domain users can access this domain’s resources |
| Outgoing Trust | This domain's users can access the other domain’s resources |
| Two-Way Trust | Both domains trust each other |
🔐 Transitive vs Non-Transitive Trust
- Transitive: Trust extends beyond immediate domains (A trusts B, B trusts C → A trusts C)
- Non-Transitive: Trust exists only between two domains directly
🛡 Authentication Scope Options
- Domain-wide / Forest-wide Authentication: All users automatically authenticated
- Selective Authentication: Explicit permission required for each server
🔐 How Kerberos Authentication Works Across Trusts
- User logs into Domain A.
- User requests access to resource in Domain B.
- Domain A DC issues a referral TGT for Domain B.
- User presents referral to Domain B DC.
- Domain B issues service ticket.
- User accesses resource.
This process uses Kerberos referral tickets and relies on the trust path.
🔎 SID Filtering (Security Protection)
SID filtering prevents malicious users from injecting fake SIDs from trusted domains. It is enabled by default for external trusts and recommended for forest trusts.
netdom trust domainA.com /domain:domainB.com /quarantine:yes
🛠 How to Create a Trust (GUI Method)
- Open Active Directory Domains and Trusts
- Right-click domain → Properties
- Select Trusts tab
- Click New Trust
- Enter DNS name of other domain/forest
- Select trust type (Forest, External, etc.)
- Choose trust direction
- Select authentication scope
- Complete wizard
⚡ Create Trust Using PowerShell
New-ADTrust -Name "partner.com" `
-SourceForest "abctech.com" `
-TargetForest "partner.com" `
-TrustType Forest `
-Direction Bidirectional
🔍 Verify Trust Relationships
nltest /domain_trusts
Get-ADTrust -Filter *
netdom trust abctech.com /domain:partner.com /verify
🚨 Trust Troubleshooting Commands
dcdiag
repadmin /replsummary
nltest /sc_query:domain.com
🏢 Real-World Enterprise Use Cases
- Mergers & Acquisitions
- Resource Forest Model
- Partner Company Collaboration
- Hybrid On-Prem & Cloud Integration
- Multi-national corporate forests
🔐 Trust Security Best Practices
- Use one-way trusts when possible
- Enable SID filtering
- Limit Domain Admin access across forests
- Audit cross-domain authentication events
- Document trust relationships formally
- Regularly review and remove unused trusts
2.6 Designing AD Structure for Enterprises
🎯 Design Considerations
Designing an Active Directory structure is a critical task that must balance business requirements, security, scalability, and operational efficiency. Key factors to consider:
- Business structure: Departments, divisions, subsidiaries, geographical locations.
- Security requirements: Isolation needs (e.g., R&D must be separated from corporate network).
- Regulatory compliance: Data sovereignty, privacy laws (e.g., GDPR).
- Network constraints: WAN bandwidth, latency, and replication traffic.
- Administrative model: Centralized vs. decentralized IT management.
- Scalability: Expected growth in objects and domains.
🌲 Forest Design Decisions
- Single forest: Simplest, suitable for most organizations. All domains share schema and configuration. Provides full trust and collaboration. Security boundary is the forest.
-
Multiple forests: Required for:
- Legal or regulatory separation (e.g., subsidiaries that must operate independently).
- Schema isolation (applications with conflicting schema extensions).
- Test/development environments isolated from production.
- Partner or extranet scenarios (limited trust).
📁 Domain Design Decisions
Within a forest, you need to decide how many domains to create. Options:
- Single domain model: All objects in one domain. Simplest to manage, all users and computers are under one administrative umbrella. Suitable for most small to medium organizations.
-
Multiple domains model: May be needed for:
- Decentralized administration: Each business unit manages its own domain.
- Policy differences: Different password policies or account lockout settings (though fine-grained password policies in a single domain can address this).
- Replication control: Large organizations with many objects may split domains to reduce replication traffic (less common now).
- Legacy or political reasons: Mergers, acquisitions.
📂 OU Design Best Practices
- Keep the hierarchy simple: No more than 3–5 levels deep.
- Model after business functions, not individual users: Use OUs for departments, locations, or roles.
- Separate users and computers: Create top-level OUs for Users and Computers, then sub-OUs under each.
- Plan for GPO application: GPOs are processed in order: Local, Site, Domain, OU. Use OUs to scope policies.
- Delegate at the OU level: Assign administrative permissions to the appropriate OUs.
- Avoid moving objects frequently: GPO and permission inheritance changes can cause temporary access issues.
🏢 Real-World Example: Contoso Corporation
Contoso is a multinational company with headquarters in New York, a large R&D center in Munich, and sales offices in Tokyo and São Paulo.
They have a single forest named contoso.com with one domain for simplicity. Within the domain, they create an OU structure:
contoso.com (domain)
├── Users
│ ├── Executives
│ ├── IT
│ ├── Sales
│ ├── R&D
│ └── Finance
├── Computers
│ ├── Workstations
│ │ ├── NewYork
│ │ ├── Munich
│ │ ├── Tokyo
│ │ └── SaoPaulo
│ └── Servers
├── Groups
│ ├── Security
│ └── Distribution
└── Service Accounts
They delegate password reset permissions for each location's helpdesk to the respective Workstations sub-OU. They apply GPOs at the domain level for basic security, at the location OUs for regional settings (e.g., time zone, language), and at department OUs for specific software deployments.
The best AD structure is one that balances business needs with technical simplicity. Start with a single forest and single domain, then expand only when required by clear, documented requirements. OU design should be flexible enough to accommodate future changes.
🎓 Module 02 : Forest, Domain, OU Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 03 : Users, Groups & Computers – Deep Dive
This module provides an in‑depth exploration of the three core object types in Active Directory: users, groups, and computers. You will learn how to create and manage user accounts, understand the differences between security and distribution groups, master group scopes (global, universal, domain local), and discover the intricacies of computer accounts. Additionally, we cover password policies, account lockout mechanisms, and the critical concept of delegating administrative control. Each topic is packed with real‑world examples, best practices, and PowerShell commands to prepare you for managing a production AD environment.
3.1 Creating & Managing Users in Active Directory
👤 What is a User Object in Active Directory?
A User Object in Active Directory represents a digital identity for a person, service, or application. It allows authentication, authorization, and access to network resources like files, email, printers, and applications.
📝 Step-by-Step: Create a User Account (GUI Method)
- Open Active Directory Users and Computers (ADUC)
- Navigate to the correct Organizational Unit (OU)
- Right-click OU → New → User
- Enter First Name, Last Name
- Set User Logon Name (UPN) (e.g., john.smith@company.com)
- Set password
- Select options:
- User must change password at next logon
- Password never expires (avoid unless required)
- Account disabled (if pre-staging)
- Click Finish
⚡ Create User Using PowerShell (Enterprise Method)
New-ADUser -Name "John Smith" `
-GivenName John `
-Surname Smith `
-SamAccountName jsmith `
-UserPrincipalName jsmith@company.com `
-Path "OU=Sales,DC=company,DC=com" `
-AccountPassword (ConvertTo-SecureString "P@ssw0rd123" -AsPlainText -Force) `
-Enabled $true `
-ChangePasswordAtLogon $true
PowerShell is recommended for automation and bulk user provisioning.
📂 Bulk User Creation (CSV Method)
Import-Csv users.csv | ForEach-Object {
New-ADUser -Name $_.Name `
-GivenName $_.FirstName `
-Surname $_.LastName `
-SamAccountName $_.Username `
-UserPrincipalName "$($_.Username)@company.com" `
-Path "OU=Users,DC=company,DC=com" `
-AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -Force) `
-Enabled $true
}
Used during:
- Company mergers
- New office setup
- HR onboarding automation
🔧 Managing User Accounts (Daily Admin Tasks)
- Reset Password: Right-click → Reset Password
PowerShell:Set-ADAccountPassword -Identity jsmith -Reset - Enable / Disable Account:
Enable-ADAccount jsmithDisable-ADAccount jsmith - Add to Group:
Add-ADGroupMember -Identity "Sales_Group" -Members jsmith - Move to another OU:
Move-ADObject -Identity "CN=John Smith,OU=Sales,DC=company,DC=com" -TargetPath "OU=HR,DC=company,DC=com"
🔐 User Account Security Best Practices
- Follow Least Privilege Principle
- Use separate Admin account (no daily use)
- Enable Multi-Factor Authentication (if hybrid)
- Disable inactive accounts (90+ days)
- Never enable "Password Never Expires" unless required
- Monitor failed logon attempts
🔁 User Lifecycle Management (Joiner – Mover – Leaver Model)
- Joiner: Create account → Assign groups → Set permissions
- Mover: Update department → Change group membership → Move OU
- Leaver: Disable account → Remove from groups → Archive mailbox → Delete after retention period
📊 Advanced Monitoring & Reporting
- Find inactive users:
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 - Find locked accounts:
Search-ADAccount -LockedOut - Audit logon activity via Event Viewer
🏢 Real-World Enterprise Example
ABC Technologies uses automated HR integration:
- HR adds employee → Account auto-created via script
- Department-based OU placement
- Group membership auto-assigned
- Access based on role (RBAC model)
- Termination triggers automatic disable process
3.2 Security vs Distribution Groups in Active Directory
🔑 What Are Active Directory Groups?
In Active Directory, groups are used to simplify management of users, permissions, and communication. Instead of assigning permissions to individual users, administrators assign permissions to groups — and users become members of those groups.
🛡️ Security Groups (Access Control Groups)
Security Groups are used to assign permissions to resources such as files, folders, printers, applications, and even Group Policies.
Key Features:
- Have a unique Security Identifier (SID)
- Can be used in Access Control Lists (ACLs)
- Can be nested (depending on scope)
- Appear in user access tokens during logon
- Can be mail-enabled (Exchange integration)
📧 Distribution Groups (Email Groups)
Distribution Groups are used only for email distribution. They do NOT have a SID and cannot be assigned permissions.
Key Features:
- Used only for email communication
- Cannot be used in ACLs
- Do not appear in access tokens
- Primarily used in Exchange environments
📊 Security vs Distribution Groups (Comparison Table)
| Feature | Security Group | Distribution Group |
|---|---|---|
| Has SID | Yes | No |
| Used for Permissions | Yes | No |
| Email Capable | Yes (if mail-enabled) | Yes |
| Appears in Access Token | Yes | No |
| Used in GPO Security Filtering | Yes | No |
🛠️ Step-by-Step: Create a Security or Distribution Group (GUI)
- Open Active Directory Users and Computers (ADUC)
- Navigate to correct OU
- Right-click → New → Group
- Enter group name (e.g., G_Sales)
- Select:
- Group Scope (Domain Local / Global / Universal)
- Group Type (Security or Distribution)
- Click OK
⚡ Create Group Using PowerShell
New-ADGroup -Name "G_Sales" ` -GroupScope Global ` -GroupCategory Security ` -Path "OU=Groups,DC=company,DC=com"
To create Distribution group:
New-ADGroup -Name "D_Sales" ` -GroupScope Global ` -GroupCategory Distribution ` -Path "OU=Groups,DC=company,DC=com"
🌍 Understanding Group Scope (Very Important)
- Domain Local: Used to assign permissions within same domain
- Global: Contains users from same domain
- Universal: Can contain users from multiple domains
🏢 Enterprise Best Practice: AGDLP Model
Microsoft recommends using the AGDLP model for permission management:
- A = Accounts (Users)
- G = Global Groups
- D = Domain Local Groups
- LP = Local Permissions
Example:
- Add Users → Global Group
- Add Global Group → Domain Local Group
- Assign Domain Local Group → Folder Permission
🔄 Converting Between Group Types
Set-ADGroup -Identity "MyGroup" -GroupCategory Distribution
⚠️ Be careful: converting a security group to distribution will remove its ability to hold permissions.
🔐 Security Best Practices
- Use naming convention (G_ for security, D_ for distribution)
- Avoid assigning permissions directly to users
- Review group membership regularly
- Limit nesting depth
- Audit privileged groups (Domain Admins, Enterprise Admins)
🏢 Real-World Corporate Example
ABC Technologies implements:
- G_Sales → Security group for shared drive access
- D_Sales → Distribution group for announcements
- Global groups nested into Domain Local groups
- Automated provisioning via PowerShell scripts
3.3 Group Scope in Active Directory (Global, Universal, Domain Local)
🌐 What is Group Scope?
In Active Directory, group scope defines:
- What objects the group can contain (membership rules)
- Where the group can be used (permission assignment location)
- How group membership replicates across the forest
🌍 Global Groups
Purpose: Used to organize users based on job roles within the same domain.
Can Contain:
- Users from same domain
- Computers from same domain
- Other Global groups (same domain)
Can Be Used In:
- Any domain in the forest
- Trusted forests
Replication:
- Stored in domain partition
- Replicates only inside its own domain
🏠 Domain Local Groups
Purpose: Assign permissions to resources located in the same domain.
Can Contain:
- Users from any domain
- Global groups from any domain
- Universal groups
- Domain local groups (same domain only)
Can Be Used In:
- Only in the domain where created
Replication:
- Replicates only inside its own domain
🌎 Universal Groups
Purpose: Used when membership spans multiple domains.
Can Contain:
- Users from any domain
- Global groups from any domain
- Other Universal groups
Can Be Used In:
- Any domain in the forest
- Trusted forests
Replication:
- Stored in Global Catalog
- Membership replicates forest-wide
- Frequent changes increase replication traffic
📊 Group Scope Comparison
| Scope | Contains | Permission Scope | Replication | Best Use |
|---|---|---|---|---|
| Global | Same-domain users & global groups | Any domain | Domain only | Role grouping |
| Domain Local | Users & groups from any domain | Home domain only | Domain only | Resource permissions |
| Universal | Users & global groups from any domain | Any domain | Forest-wide | Cross-domain grouping |
🏢 Enterprise Best Practice: AGDLP Model
AGDLP = Accounts → Global → Domain Local → Permissions
- Add Users → Global group (G_Sales)
- Add Global group → Domain Local group (DL_Sales_RW)
- Assign DL group → Folder permission
🌍 Multi-Domain Enterprise Model: AGUDLP
AGUDLP = Accounts → Global → Universal → Domain Local → Permissions
- Users → Global group (per domain)
- Global groups → Universal group
- Universal group → Domain Local group (resource domain)
- Domain Local group → Permissions
🛠️ Create Groups Using PowerShell
# Global Group New-ADGroup -Name "G_Sales" -GroupScope Global -GroupCategory Security -Path "OU=Groups,DC=company,DC=com" # Domain Local Group New-ADGroup -Name "DL_Sales_RW" -GroupScope DomainLocal -GroupCategory Security -Path "OU=Groups,DC=company,DC=com" # Universal Group New-ADGroup -Name "U_AllEmployees" -GroupScope Universal -GroupCategory Security -Path "OU=Groups,DC=company,DC=com"
🔄 Changing Group Scope (Important Rules)
- Global → Universal (Allowed if no nested global groups from other domains)
- Universal → Global (Only if no foreign members)
- Domain Local → Universal (Allowed under restrictions)
Set-ADGroup -Identity "G_Sales" -GroupScope Universal
🔐 Security & Performance Considerations
- Avoid deep nesting
- Limit Universal group changes
- Use naming conventions (G_, DL_, U_)
- Audit privileged group membership
- Follow AGDLP consistently
🎯 Real-World Example
ABC Technologies (Multi-domain forest):
- Domain1 → G_IT_Domain1
- Domain2 → G_IT_Domain2
- Both → U_IT_All
- U_IT_All → DL_ServerAccess
- DL_ServerAccess → File server permission
3.4 Computer Accounts in Active Directory
💻 What is a Computer Account?
A Computer Account in Active Directory represents a domain-joined device such as a workstation, laptop, server, or domain controller.
Just like user accounts, computer accounts are security principals. They have:
- A unique Security Identifier (SID)
- A password (machine password)
- An authentication relationship with domain controllers
- The ability to receive Group Policy
➕ How to Join a Computer to the Domain
Method 1 – GUI Method
- Right-click This PC → Properties
- Click Change settings
- Select Change
- Choose Domain
- Enter domain name (e.g., contoso.com)
- Provide domain credentials
- Restart computer
Method 2 – PowerShell Method
Add-Computer -DomainName "contoso.com" ` -Credential CONTOSO\AdminUser ` -OUPath "OU=Workstations,OU=Computers,DC=contoso,DC=com" ` -Restart
🏗️ Pre-Staging Computer Accounts (Enterprise Best Practice)
Instead of letting users create computer objects automatically, administrators can pre-create (prestaged) computer accounts in the correct OU.
Benefits:
- Correct OU placement
- Proper Group Policy application
- Controlled delegation
- Improved security
🔑 Computer Account Password Management
Every domain-joined computer automatically changes its machine password every 30 days by default using the NetLogon service.
If the secure channel breaks (e.g., after restoring old image), fix it:
- PowerShell:
Reset-ComputerMachinePassword -Server DC01 - NetDom:
netdom resetpwd /s:DC01 /ud:domain\Admin /pd:* - ADUC: Right-click computer → Reset Account
🗂️ Important Computer Account Attributes
cn– Computer namesAMAccountName– Name with $ (WS-001$)dNSHostName– Fully qualified domain nameoperatingSystem– OS versionpwdLastSet– Last machine password changelastLogonTimestamp– Last domain authenticationuserAccountControl– 4096 for workstations
🔄 Managing Computer Accounts with PowerShell
# List all computers Get-ADComputer -Filter * -Properties OperatingSystem | Select Name, OperatingSystem # Disable computer Disable-ADAccount -Identity "WS-001$" # Move to another OU Move-ADObject -Identity "CN=WS-001,OU=Computers,DC=contoso,DC=com" ` -TargetPath "OU=Workstations,DC=contoso,DC=com" # Find inactive computers (90 days) Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan 90.00:00:00
🔐 Computer Account Security Best Practices
- Restrict who can join computers to domain
- Use GPO to control local administrator group
- Enable LAPS (Local Administrator Password Solution)
- Monitor inactive computer accounts
- Disable unused machines before deletion
- Protect Domain Controllers OU
🖥️ Domain Controller Computer Accounts
Domain Controllers are special computer accounts:
- Located in Domain Controllers OU
userAccountControl= 8192- Member of Domain Controllers group
- Hold Active Directory database (NTDS.dit)
🏢 Real-World Enterprise Lifecycle
- Provisioning: Pre-stage account → Join to domain
- Management: Apply GPO → Patch → Monitor
- Decommission: Disable → Remove from domain → Delete after audit period
3.5 Password Policies & Account Lockout in Active Directory
🔐 What is a Domain Password Policy?
The Domain Password Policy defines password security rules for all users in an Active Directory domain. It is configured in the Default Domain Policy Group Policy Object (GPO).
⚙️ Where to Configure Password Policy
Open:
- Group Policy Management Console (GPMC)
- Edit Default Domain Policy
- Navigate to:
Computer Configuration → Policies → Windows Settings → Security Settings → Account Policies → Password Policy
📋 Important Password Policy Settings
- Enforce Password History: Prevent reuse of old passwords (Recommended: 24)
- Maximum Password Age: How long password is valid (Recommended: 60–90 days)
- Minimum Password Age: Prevent immediate reuse (Recommended: 1 day)
- Minimum Password Length: Recommended 12+ characters
- Password Complexity: Uppercase, lowercase, number, symbol
- Reversible Encryption: Keep Disabled (Security Risk)
🔒 Account Lockout Policy
Account lockout protects against brute-force password attacks.
- Lockout Threshold: Failed attempts before lock (Recommended: 5)
- Lockout Duration: 15–30 minutes
- Reset Lockout Counter After: 15–30 minutes
⛔ Unlocking Locked Accounts
- GUI: ADUC → Right-click User → Unlock Account
- PowerShell:
Unlock-ADAccount -Identity jsmith
To identify lockout source:
Check PDC Emulator Event Viewer → Event ID 4740
🔁 Fine-Grained Password Policies (FGPP)
Introduced in Windows Server 2008, Fine-Grained Password Policies (FGPP) allow different password rules for different groups within the same domain.
Create FGPP Using PowerShell
New-ADFineGrainedPasswordPolicy -Name "AdminPolicy" ` -Precedence 100 ` -MinPasswordLength 15 ` -ComplexityEnabled $true ` -LockoutThreshold 3 ` -MaxPasswordAge "30.00:00:00" Add-ADFineGrainedPasswordPolicySubject ` -Identity "AdminPolicy" ` -Subjects "CN=Domain Admins,CN=Users,DC=contoso,DC=com"
📊 View Effective Password Policy
Get-ADUserResultantPasswordPolicy -Identity jsmith
This shows which password policy actually applies to the user.
📈 Password Policy Precedence Rules
- PSO applied directly to user
- PSO applied via group (lowest precedence wins)
- If none, Default Domain Policy applies
🔐 Enterprise Security Best Practices
- Use 12–16 character passwords minimum
- Encourage passphrases (e.g., MySecureCompany2024!)
- Enable Multi-Factor Authentication (MFA)
- Remove frequent forced password changes unless required
- Apply stricter policy to admin accounts
- Monitor account lockout spikes
- Enable Azure AD Password Protection (if hybrid)
🛡️ Common Security Risks
- Weak passwords
- Password spraying attacks
- Brute-force attacks
- Service accounts with expired passwords
- Shared admin credentials
🏢 Real-World Enterprise Example
- Standard Users: 12 characters, 60-day expiry
- Administrators: 15+ characters, 30-day expiry, MFA required
- Service Accounts: 25+ characters, managed via gMSA
- Lockout Threshold: 5 attempts
3.6 Delegation of Administrative Control in Active Directory
🎯 What is Delegation in Active Directory?
Delegation of Administrative Control allows you to grant limited administrative permissions to users or groups without giving them full Domain Admin rights.
Delegation follows the Principle of Least Privilege — users receive only the permissions necessary to perform their job.
🔧 How Delegation Works
Delegation is implemented using Access Control Lists (ACLs) on:
- Organizational Units (OUs)
- Containers
- Individual objects (Users, Groups, Computers)
Each permission grants specific rights such as:
- Create objects
- Delete objects
- Reset passwords
- Modify group membership
- Read attributes
- Write attributes
🛠️ Step-by-Step: Using the Delegation of Control Wizard
- Open Active Directory Users and Computers (ADUC)
- Right-click the target OU → Delegate Control
- Add the security group (e.g., Helpdesk)
- Select predefined tasks:
- Reset user passwords
- Create/delete user accounts
- Manage groups
- Read user information
- Click Finish
🧩 Custom Delegation (Advanced)
Choose Create a custom task to delegate to assign very specific permissions. Example:
- Allow Helpdesk to only reset passwords
- Allow Team Lead to modify group membership only
- Allow Branch IT to manage computers only
⚡ Delegation Using PowerShell (Advanced Method)
$ou = "OU=Sales,DC=contoso,DC=com" $user = "CONTOSO\Helpdesk" $acl = Get-Acl "AD:$ou" $identity = [System.Security.Principal.NTAccount]$user $rights = [System.DirectoryServices.ActiveDirectoryRights]"ExtendedRight" $type = [System.Security.AccessControl.AccessControlType]"Allow" $inheritance = [System.DirectoryServices.ActiveDirectorySecurityInheritance]"All" $guid = [System.Guid]"00299570-246d-11d0-a768-00aa006e0529" # Reset Password GUID $rule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule($identity, $rights, $type, $guid, $inheritance) $acl.AddAccessRule($rule) Set-Acl -Path "AD:$ou" -AclObject $acl
⚠️ Manual ACL modification is complex — use the wizard unless you understand AD schema GUIDs.
🏢 Common Delegation Scenarios (Enterprise Examples)
- Helpdesk: Reset passwords, unlock accounts
- HR Admin: Create and disable user accounts
- Application Team: Manage service accounts
- Branch Office IT: Join computers to domain
- Department Manager: Manage group membership
🔐 Delegation and Group Policy (GPO)
You can delegate control over Group Policy Objects (GPOs):
- Create GPOs
- Edit existing GPOs
- Link GPOs to OUs
Use Group Policy Management Console (GPMC) → Delegation tab.
🏗️ Tiered Administrative Model (Security Best Practice)
- Tier 0: Domain Controllers, Enterprise Admins
- Tier 1: Server Administrators
- Tier 2: Workstation & Helpdesk Admins
🔍 Auditing Delegated Activity
Enable auditing for Directory Service Changes:
- Event ID 5136 – Object modified
- Event ID 5137 – Object created
- Event ID 5141 – Object deleted
- Event ID 4723 – Password change
- Event ID 4724 – Password reset
Monitor logs on the PDC Emulator.
⚠️ Common Delegation Mistakes
- Granting Full Control unnecessarily
- Delegating at domain root instead of OU
- Using individual users instead of groups
- Not documenting delegated rights
- Ignoring periodic review of delegated permissions
📊 Delegation Best Practices
- Delegate at OU level only
- Use clearly named security groups (e.g., DL_Helpdesk_ResetPwd)
- Review permissions quarterly
- Use RBAC (Role-Based Access Control)
- Combine delegation with auditing
🎓 Module 03 : Users, Groups & Computers – Deep Dive Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 04 : Group Policy (GPO)
This module provides an exhaustive exploration of Group Policy, the cornerstone of centralized configuration management in Active Directory. You will learn what Group Policy is, how it is structured, and the order in which policies are processed. We delve into enforcing password policies, deploying software via GPO, understanding loopback processing, and troubleshooting common GPO issues. By the end of this module, you will be equipped to design, implement, and maintain Group Policy in any enterprise environment.
4.1 What is Group Policy?
🔍 Definition: Group Policy Explained Simply
Group Policy is Microsoft's centralized configuration management framework within Active Directory. It allows administrators to define security settings, deploy software, configure desktop environments, and enforce rules across thousands of computers and users – all from a single management console.
Imagine you own a restaurant chain with 500 locations. Instead of visiting each restaurant to train staff, set menus, and enforce hygiene rules, you create a standard operations manual (Group Policy). Every restaurant automatically follows this manual. If you want to change the menu or update safety protocols, you update the manual once, and all locations instantly comply. Group Policy is that operations manual for your IT environment.
📊 Quick Facts
- Introduced: Windows 2000
- Management: Centralized
- Scope: Users & Computers
- Storage: AD + SYSVOL
- Settings: 4000+ configurable
🧩 Core Components of Group Policy (The Building Blocks)
Understanding Group Policy requires knowing its four fundamental components and how they work together:
A GPO is a virtual collection of policy settings. Think of it as a container that holds all the rules you want to apply.
Real-world analogy: A GPO is like a recipe book containing specific instructions (settings) for your IT kitchen.
Technical details:
- Each GPO has a unique GUID (e.g., {31B2F340-016D-11D2-945F-00C04FB984F9})
- Stored in two locations: AD (GPC) and SYSVOL (GPT)
- Can be linked to multiple containers (sites, domains, OUs)
The GPC is stored in Active Directory under CN=System,CN=Policies. It contains metadata about the GPO.
What it stores:
- Version information (to detect changes)
- Status (enabled/disabled)
- Path to the GPT in SYSVOL
- WMI filter references
Think of it as the table of contents that tells clients where to find the actual recipe.
The GPT is stored in the SYSVOL share: \\domain\SYSVOL\domain\Policies\{GPO-GUID}
Contents include:
Registry.pol– Contains registry settingsScripts– Startup/shutdown/logon/logoff scriptsApplications– Software installation packagesSecurity– Security template settings
This is the actual recipe book with all the detailed instructions.
ADMX files define registry-based policy settings in a language-neutral format. They control thousands of Windows settings.
Location:
- Local:
C:\Windows\PolicyDefinitions - Central Store:
\\domain\SYSVOL\domain\Policies\PolicyDefinitions
Think of these as pre-written recipe templates you can customize.
📊 Local vs Domain Group Policy: Key Differences
| Feature | Local Group Policy (LGPO) | Domain Group Policy |
|---|---|---|
| Scope | Single computer only | Entire domain, site, or OU (thousands of computers) |
| Storage Location | %SystemRoot%\System32\GroupPolicy |
AD (GPC) + SYSVOL (GPT) |
| Management | Local gpedit.msc |
GPMC, PowerShell, remote management |
| Number of GPOs | Only one (Local Policy) | Unlimited (thousands possible) |
| Settings Available | Limited subset | Full range including security, software deployment, folder redirection |
| Processing Order | Always processed first (lowest priority) | Processed after local (higher priority) |
| Analogy | Personal notebook of rules for one person | Company-wide policy manual for all employees |
⚙️ How GPOs Are Applied: The Step-by-Step Process
When a Windows computer starts or a user logs on, this is what happens behind the scenes:
- Computer starts up – The NetLogon service establishes a secure channel with a domain controller.
- Discovers which GPOs apply – The client queries AD to find all GPOs linked to the computer's site, domain, and OU (including inherited GPOs).
- Downloads GPO information – The client reads the GPC in AD to get version info and GPT location.
- Checks version – Compares local cached version with server version. If newer, downloads the GPT from SYSVOL.
- Processes computer configuration – Applies registry settings, runs startup scripts, installs software, etc.
- User logs on – The process repeats for user-specific GPOs (user configuration).
- Applies user settings – Folder redirection, logon scripts, desktop preferences, etc.
- Periodic refresh – Every 90-120 minutes, the client checks for GPO updates and applies changes in the background.
⏱️ Refresh Timeline
- Security settings: Every 16 hours (even if no changes)
- Software installation: At startup/logon only
- Folder redirection: At logon only
- Registry policies: Every 90-120 mins + 30 min offset
gpupdate /force – Manual refresh command
📂 GPO Storage: Where Everything Lives
Active Directory (GPC) SYSVOL (GPT)
────────────────────────── ──────────────────────────
CN=Policies,CN=System,DC=domain \domain\SYSVOL\domain\Policies
├── {GPO-GUID-1} ├── {GPO-GUID-1}/
│ ├── cn={GPO-GUID-1} │ ├── GPT.INI (version info)
│ ├── displayName: "Default Domain Policy" │ ├── USER/
│ ├── versionNumber: 65537 (0x10001) │ │ └── Registry.pol
│ └── (other metadata) │ └── MACHINE/
└── {GPO-GUID-2} │ ├── Registry.pol
├── ... │ ├── Scripts/
│ └── Applications/
└── {GPO-GUID-2}/
└── ...
Note: The version number must match between GPC and GPT for the GPO to be considered synchronized.
🛠️ Group Policy Management Tools: Which One to Use?
| Tool | Best For | How to Access | Example Use |
|---|---|---|---|
| GPMC (Group Policy Management Console) | Complete GPO lifecycle management | gpmc.msc (RSAT required) |
Creating, linking, backing up GPOs; viewing RSoP |
| GPE (Group Policy Editor) | Editing individual GPO settings | Launched from GPMC or gpedit.msc (local) |
Configuring specific policies like password requirements |
| PowerShell (GroupPolicy module) | Automation and scripting | Import-Module GroupPolicy |
Bulk GPO creation, reporting, backups |
| RSOP.msc | Viewing applied policies on local machine | rsop.msc |
Troubleshooting what policies are actually applied |
| ADAC (Active Directory Administrative Center) | Basic GPO management integrated with AD | Server Manager → Tools → ADAC | Quick GPO creation when already in ADAC |
📁 ADMX Central Store: Why It Matters
Problem before Central Store: Each administrator's computer had its own set of ADMX files (from different Windows versions). When editing GPOs, administrators might see different settings depending on their local ADMX versions, leading to inconsistencies.
Solution – Central Store:
- Create the folder:
\\domain\SYSVOL\domain\Policies\PolicyDefinitions - Copy all ADMX and ADML files from a Windows client/Server to this folder.
- All administrators now use the same centralized ADMX files when editing any GPO.
Benefits:
- Consistent administrative experience across all management workstations
- Support for custom ADMX files from third-party applications
- Version control – you control which ADMX versions are used
📌 Central Store Location
\contoso.com\SYSVOL
└── contoso.com
└── Policies
└── PolicyDefinitions
├── en-US (language folder)
│ ├── inetres.adml
│ ├── System.adml
│ └── ...
├── inetres.admx
├── System.admx
└── ...
Copy ADMX files from: C:\Windows\PolicyDefinitions
💻 Essential Group Policy Commands (Cheat Sheet)
| Command | Purpose | Example |
|---|---|---|
gpupdate |
Refresh Group Policy settings | gpupdate /target:computer (computer only) |
gpupdate /force |
Force a refresh (reapply all settings) | gpupdate /force /sync (synchronous processing) |
gpresult /r |
Display RSoP summary for user/computer | gpresult /scope:computer /r |
gpresult /h report.html |
Generate HTML report of applied policies | gpresult /h C:\gpreport.html /f |
Get-GPO -All |
List all GPOs in domain (PowerShell) | Get-GPO -All | Select DisplayName, ID |
Backup-GPO |
Backup a GPO to file system | Backup-GPO -Name "Default Domain Policy" -Path C:\Backups |
🏢 Real-World Enterprise Example
Business Requirements:
- Enforce strong password policies across all users
- Deploy company wallpaper to all workstations
- Restrict USB access for non-IT staff
- Deploy Adobe Reader to all computers
- Configure time zones based on location
Solution Design:
- GPO_Domain_Security: Password policy, account lockout (linked to domain)
- GPO_Wallpaper: Desktop wallpaper setting (linked to Computers OU)
- GPO_USB_Restriction: Disable USB storage (linked to Workstations OU)
- GPO_Adobe_Reader: Software deployment (linked to Computers OU)
- GPO_TimeZone_Site: Site-linked GPOs for time zones
❓ Common Group Policy Misconceptions (Cleared Up)
"Group Policy is the same as Local Security Policy"
Local Security Policy is just a subset of Group Policy. Group Policy includes hundreds more settings and can be centrally managed.
"Changes to GPOs take effect immediately everywhere"
Changes must replicate to all DCs, then clients must refresh (up to 120 minutes by default). Use gpupdate /force on clients for immediate effect.
"If I delete a GPO, all settings are removed from clients"
When a GPO is deleted, its settings remain on clients until they are overwritten by another policy or manually reversed. Some settings (like registry policies) persist indefinitely.
🎯 Key Takeaways – 4.1 What is Group Policy?
- Group Policy is Microsoft's centralized configuration management for AD environments
- GPOs consist of two parts: GPC (metadata in AD) and GPT (settings in SYSVOL)
- Local Policy applies to one machine; Domain Policy applies to thousands
- ADMX Central Store ensures consistent policy editing across administrators
- GPMC, PowerShell, and
gpupdate/gpresultare essential tools - Changes take time to propagate – plan accordingly
📘 SEO Summary – Group Policy Definition
Group Policy (GPO) is a feature of Microsoft Active Directory that enables centralized management of user and computer settings in Windows domain environments. Administrators use Group Policy to enforce security policies, deploy software, configure desktop settings, and manage scripts across thousands of machines. Group Policy Objects (GPOs) are stored in two locations: the Group Policy Container (GPC) in Active Directory and the Group Policy Template (GPT) in the SYSVOL share. Tools like Group Policy Management Console (GPMC), PowerShell, and gpresult are used to create, link, edit, and troubleshoot GPOs. Understanding Group Policy is essential for Windows Server administration, cybersecurity hardening, and enterprise IT management.
4.2 GPO Structure & Processing Order
🧩 LSDOU – The Processing Hierarchy
Group Policies are processed in a strict order, often remembered by the acronym LSDOU:
- Local – Local computer policy (least priority).
- Site – GPOs linked to the Active Directory site where the computer resides.
- Domain – GPOs linked at the domain level.
- OU – GPOs linked to the OU containing the computer or user, processed from parent OU down to child OU (deepest OU has highest priority).
For example, if a setting is defined in both a domain‑level GPO and an OU‑level GPO, the OU‑level setting wins (last writer wins). This order applies separately for computer and user configurations.
🔄 Inheritance, Blocking, and Enforcing
- Inheritance: By default, child OUs inherit GPOs linked to parent OUs.
- Block Inheritance: On a domain or OU, you can check “Block inheritance” to prevent GPOs from higher levels (site, domain, parent OUs) from applying to that container. However, enforced GPOs (see below) override block.
- Enforced (No Override): When you set a GPO link to “Enforced”, its settings cannot be overridden by any GPO lower in the hierarchy (including those that block inheritance). Enforced GPOs have the highest priority.
🔗 Linking GPOs
A GPO is not active until it is linked to a site, domain, or OU. One GPO can be linked to multiple containers. The order of processing for multiple GPOs linked to the same container is determined by the link order (lowest number processed last, thus highest priority). You can change link order in GPMC.
⚙️ Processing Details: Computer vs User Configuration
- Computer Configuration: Applied during system startup. It runs in the security context of the computer (SYSTEM).
- User Configuration: Applied during user logon. It runs in the context of the logged‑on user.
Both sections are independent; a GPO can contain settings for both computers and users. The actual application order for a given session is: computer policies first, then user policies (after logon).
⏱️ Refresh Interval and Background Processing
Group Policy is reapplied periodically in the background (every 90–120 minutes by default, with a random offset). This ensures that changes take effect even without a reboot or logoff. Security settings and some policies (like software installation) typically require a restart or logoff.
📊 GPO Versioning and Replication
Each GPO has a version number stored in both the GPC (AD) and GPT (SYSVOL). Clients compare these versions; if they differ, the client downloads the latest GPT. Domain controllers replicate both AD and SYSVOL, so GPO changes must replicate across all DCs before they are consistently applied. Use gpupdate /force to manually trigger a refresh.
4.3 Enforcing Password Policies in Active Directory
🔐 Why Password Policies Matter
Password policies are the first line of defense against unauthorized access in any organization. In Active Directory, they define the rules for creating, using, and managing passwords for all domain users. A well-designed password policy significantly reduces the risk of brute‑force attacks, password guessing, and credential theft.
Think of password policies as the locks on your office doors. A weak lock (simple password) is easy to pick; a strong lock (complex password) deters attackers. But even the strongest lock is useless if everyone uses the same key (shared passwords) or if keys are never changed (no password expiry). Password policies ensure that every employee has a unique, strong key that is changed regularly.
📊 Quick Stats
- 81% of data breaches involve weak or stolen passwords.
- 12+ characters recommended for modern passwords.
- MFA blocks 99.9% of account compromise attacks.
⚙️ Default Password Policy Settings (Where to Find Them)
Password policies are configured in the Default Domain Policy GPO (or any GPO linked to the domain) under:
Computer Configuration → Policies → Windows Settings → Security Settings → Account Policies → Password Policy
Here are the key settings with explanations and recommended values based on modern security guidelines:
| Setting | Description | Default (Windows) | Modern Recommendation |
|---|---|---|---|
| Enforce password history | Number of unique new passwords required before an old password can be reused. Prevents users from cycling through favorite passwords. | 24 | 24 (keep high) |
| Maximum password age | How long (in days) a password can be used before the user must change it. | 42 | 60–90 (or 0 = never expire, if combined with MFA and strong passwords) |
| Minimum password age | How many days a password must be used before it can be changed again. Prevents users from immediately reverting to an old password after a forced change. | 1 | 1 |
| Minimum password length | Shortest allowed password. | 7 | 12–16 (long passphrases are better than short complex ones) |
| Password must meet complexity requirements | Requires passwords to contain characters from at least three of the following four categories: uppercase, lowercase, digits, non‑alphanumeric. | Enabled | Enabled (but consider passphrases instead) |
| Store passwords using reversible encryption | Stores passwords in a format that can be decrypted (essentially plaintext). Extremely dangerous – only enable if required for legacy applications (e.g., Digest Authentication). | Disabled | ❌ Disabled – NEVER enable unless absolutely necessary |
🔒 Account Lockout Policy (Protecting Against Brute‑Force)
Located in the same GPO section (Account Policies → Account Lockout Policy), these settings determine how the domain responds to repeated failed logon attempts.
| Setting | Description | Recommended |
|---|---|---|
| Account lockout duration | Minutes the account remains locked. Set to 0 for admin unlock only (not recommended for most users). | 15–30 minutes |
| Account lockout threshold | Number of failed attempts before lockout. | 5–10 (lower for admins) |
| Reset account lockout counter after | Minutes after which failed attempts are forgotten. | 15–30 (should equal or exceed lockout duration) |
🔁 Fine‑Grained Password Policies (FGPP) – Multiple Policies in One Domain
The Default Domain Policy applies to all users in the domain. But what if you need stricter rules for administrators, or relaxed rules for service accounts? That's where Fine‑Grained Password Policies (FGPP) come in. Introduced in Windows Server 2008, FGPP allows you to create multiple password policies within a single domain and apply them to different groups of users.
✅ When to Use FGPP
- Admins: Very strong passwords, frequent changes.
- Standard users: Moderate strength, standard expiry.
- Service accounts: Long, complex passwords that never expire (but must be managed securely).
- High‑security groups: Executives, finance, HR.
📋 FGPP Rules
- Each PSO (Password Settings Object) has a precedence value (lower number = higher priority).
- PSOs can be applied to users or global security groups.
- A user gets the PSO with the lowest precedence that applies to them.
🛠️ Step‑by‑Step: Create an FGPP Using Active Directory Administrative Center (ADAC)
- Open Active Directory Administrative Center (from Server Manager or run
dsac.exe). - Navigate to your domain → System → Password Settings Container.
- In the right pane, click New → Password Settings.
- Provide a name (e.g., "StrictAdminPolicy").
- Set Precedence (e.g., 10 – lower number means higher priority).
- Configure all password and lockout settings as desired.
- In the Directly Applies To section, click Add and select the users or groups (e.g., "Domain Admins").
- Click OK.
⚡ PowerShell Method (Faster for Automation)
Create a new PSO
New-ADFineGrainedPasswordPolicy -Name "StrictAdmin" -Precedence 10
-MinPasswordLength 15 -ComplexityEnabled $true
-LockoutThreshold 3 -LockoutDuration "00:30:00"
-LockoutObservationWindow "00:30:00" -PasswordHistoryCount 24
-MaxPasswordAge "30.00:00:00"
Apply it to the Domain Admins group
Add-ADFineGrainedPasswordPolicySubject -Identity "StrictAdmin" `
-Subjects "CN=Domain Admins,CN=Users,DC=contoso,DC=com"
Verify
Get-ADFineGrainedPasswordPolicy -Filter * | Format-Table Name, Precedence, AppliesTo
Get-ADUserResultantPasswordPolicy.
📊 Determining Which Password Policy Applies to a User
In a domain with FGPP, a user might be affected by multiple PSOs (via group membership). To see the effective policy:
Get-ADUserResultantPasswordPolicy -Identity jsmith
Or in ADAC, view the user and click "View resultant password settings".
🛡️ Modern Password Policy Best Practices (NIST & Microsoft Guidance)
Traditional password policies (frequent changes, complexity) often lead to user frustration and weaker passwords (e.g., "Summer2024!" then "Winter2024!"). Modern guidance from NIST (National Institute of Standards and Technology) and Microsoft recommends:
- Long passphrases over complex short passwords. Encourage sentences like "MyCatLikesFish2024!" – easier to remember, harder to crack.
- Remove mandatory periodic password changes for standard users unless there's evidence of compromise. Frequent changes often lead to weaker, predictable passwords.
- Implement Multi‑Factor Authentication (MFA) – this is the single most effective control against password‑based attacks.
- Ban common passwords (e.g., "Password123", "CompanyName2024") – use Azure AD Password Protection or custom banned password lists.
- Monitor for leaked credentials – use tools like Azure AD Identity Protection.
- Use FGPP to tailor policies for different user groups (admins, service accounts, etc.).
❌ Common Password Policy Mistakes (And How to Avoid Them)
Too short password length (e.g., 6 characters)
Set minimum length to 12+ characters; modern computers crack 8‑character passwords in minutes.
Overly aggressive lockout threshold (e.g., 3 attempts) leading to helpdesk overload.
Use 5–10 attempts with a 15‑minute lockout. Educate users on password managers to avoid typos.
Reversible encryption enabled (rare but catastrophic).
Ensure it's disabled everywhere. If an application requires it, consider alternatives or isolate that app.
One policy for all users (including admins and service accounts).
Use FGPP to create tiers. Admins need stronger policies; service accounts need very long, never‑expiring passwords (managed securely).
🏢 Real-World Enterprise Example: Contoso Corporation
Requirements:
- Meet compliance (ISO 27001, GDPR).
- Protect against brute‑force and password spraying.
- Reduce helpdesk calls for locked accounts.
- Secure privileged accounts.
Solution:
- Standard users (FGPP – "StandardUserPolicy"): Min length 12, complexity enabled, history 24, max age 90 days, lockout after 5 attempts, duration 30 min.
- Admins (FGPP – "AdminPolicy"): Min length 16, complexity enabled, history 24, max age 30 days, lockout after 3 attempts, duration 60 min. MFA mandatory.
- Service accounts (FGPP – "ServiceAccountPolicy"): Min length 25, complexity enabled, password never expires (but rotated via automated scripts).
🔍 Troubleshooting Password Policy Issues
- User can't change password – "Password does not meet requirements": Check the effective policy (
Get-ADUserResultantPasswordPolicy). The user might be subject to a stricter policy than expected. - Account locked out frequently: Check event ID 4740 on PDC Emulator to see source. Could be a stale application with old credentials.
- FGPP not applying: Ensure the group is a global security group (universal also works) and that the user is a direct or nested member. Use
Get-ADUserResultantPasswordPolicyto verify. - Default Domain Policy not applying: Make sure the GPO is linked to the domain and not blocked/enforced incorrectly. Run
gpresult /ron a client.
🎯 Key Takeaways – 4.3 Enforcing Password Policies
- Password policies are configured in the Default Domain Policy (or any domain‑linked GPO) under Account Policies.
- Core settings: history, age, length, complexity, reversible encryption (always disabled).
- Account lockout policies protect against brute‑force attacks.
- Fine‑Grained Password Policies (FGPP) allow multiple policies in one domain – essential for tiered security.
- Modern best practices: longer passphrases, reduce forced changes, enable MFA, use banned password lists.
- Always test policy changes in a pilot group before wide deployment.
📘 SEO Summary – Active Directory Password Policies
Active Directory password policies are critical for securing Windows domains against unauthorized access. Configured through Group Policy (Default Domain Policy), they enforce rules like password length, complexity, history, and expiration. The account lockout policy prevents brute‑force attacks by locking accounts after repeated failures. For organizations needing different password rules for different users, Fine‑Grained Password Policies (FGPP) allow multiple password policies within a single domain – essential for admin accounts, service accounts, and standard users. Modern guidance recommends long passphrases, multi‑factor authentication (MFA), and avoiding frequent password changes unless compromised. Properly implemented password policies are a cornerstone of Active Directory security and compliance (ISO 27001, NIST, GDPR). Use PowerShell (New-ADFineGrainedPasswordPolicy) for automation and Get-ADUserResultantPasswordPolicy to verify effective settings.
4.4 Software Deployment via GPO
📦 Overview
Group Policy can be used to deploy software packages (MSI, MSP, MSM, ZAP) to computers or users. This was a key feature for centralised software management, though modern environments often use SCCM or Intune. Still, GPO software deployment is useful in many scenarios.
📌 Assign vs Publish
- Assign: The software is installed automatically (advertised) and can be installed on demand. Assigned to computers: installation happens at next startup. Assigned to users: installation happens when the user logs on or clicks the advertised shortcut.
- Publish: The software is made available in “Add/Remove Programs” (Programs and Features) for users to install manually. Publishing is only for users, not computers.
🔧 Creating a Software Deployment GPO
- Place the installer files (e.g., .msi) on a network share with appropriate permissions (Domain Computers have Read access).
- Create or edit a GPO and navigate to Computer Configuration → Policies → Software Settings → Software installation (or User Configuration for user‑targeted).
- Right‑click → New → Package. Browse to the network share path (UNC) of the .msi.
- Select deployment method: Assigned or Published (if applicable).
- Optionally configure advanced properties: transforms (.mst), upgrades, categories, etc.
Note: Always use UNC paths, not local paths. The client must have access to the share.
🔄 Software Upgrades and Removal
- Upgrades: In the software package properties, you can specify that this package upgrades an existing package (by name). You can also set mandatory upgrade vs optional.
- Removal: To uninstall, you can either:
- Set the package to “Uninstall this application when it falls out of scope of management” – then if the GPO no longer applies (e.g., computer moved OU), the software is removed.
- Explicitly set the package to “Remove” in the GPO.
📋 File Extensions and Application Association
When you publish an application, you can configure file extension associations. For example, if you publish Adobe Reader and associate .pdf files, when a user double‑clicks a .pdf, Windows Installer may prompt to install Adobe Reader.
🛠️ Troubleshooting Software Deployment
- Application not installing: Check that the client can access the UNC share (Domain Computers must have Read). Look in Event Viewer (Applications and Services Logs → Microsoft → Windows → Group Policy → Operational) for errors.
- Slow installation: Large packages over slow links – consider using Background Intelligent Transfer (BITS) or deploying via alternate methods.
- Multiple deployment GPOs: If two GPOs assign the same package, it may install twice. Use GPO precedence to avoid.
⚠️ Limitations and Modern Alternatives
- Only supports MSI and similar formats (ZAP files are for legacy non‑MSI, but limited).
- No bandwidth throttling, no scheduling (though you can use Group Policy to set install time via scripts).
- For complex deployments, consider Microsoft Configuration Manager (SCCM) or Intune.
4.5 Loopback Processing Mode
🔄 What is Loopback?
Loopback processing is a Group Policy feature that changes how user policies are applied when a user logs on to a specific computer. Normally, user policies are applied based on the user’s location in AD. With loopback, the computer’s location can also influence the user policies – effectively replacing or merging the user’s policies with those of the computer’s OU.
🎯 When to Use Loopback
- Terminal Servers / Remote Desktop Services: Users from anywhere (with their own user policies) log on to a shared server. You want to enforce server‑specific settings (e.g., remove access to local drives, lock down the desktop) regardless of the user’s normal OU.
- Kiosk computers: Public computers that need a locked‑down shell, even for users who normally have full desktops.
- Training rooms: Where students should get a restricted environment during class, but their regular desktop outside that room is unrestricted.
⚙️ How to Configure Loopback
Loopback is enabled by editing a GPO linked to the OU containing the computers (e.g., the Terminal Servers OU). Navigate to:
Computer Configuration → Policies → Administrative Templates → System → Group Policy → Configure user Group Policy loopback processing mode.
Set it to Enabled, and choose one of two modes:
- Replace: The user’s normal GPOs (from their user object’s OU) are ignored. Only the computer’s GPOs (including those applied via the computer’s OU) determine user policy.
- Merge: The user’s normal GPOs are applied first, then the computer’s GPOs are applied. In case of conflict, the computer’s GPOs win (since they apply last).
🧪 Example: Terminal Server with Replace
Consider a terminal server in the OU “OU=TerminalServers”. A GPO linked to that OU has loopback enabled (Replace mode) and configures user settings: hide C: drive, disable control panel, set specific wallpaper. When a user (who normally gets their desktop from “OU=Sales” user policy) logs on to the terminal server, only the terminal server GPO’s user settings apply – their sales‑specific user policies are ignored. The result is a consistent, locked‑down session.
🧩 Merge Mode Example
If you want to retain some of the user’s settings but still enforce certain computer‑level overrides, use Merge. For instance, the user’s normal desktop background might be allowed, but the terminal server GPO enforces a screensaver timeout. Merge applies user policy first, then the computer’s user policy, so the screensaver timeout overrides.
🔁 Loopback and Processing Order
The processing order when loopback is enabled:
- Computer policy is applied (as usual).
- If loopback is enabled, the user policy application is modified:
- Replace: The user’s normal GPOs are ignored; only the computer’s GPOs (linked to the computer’s OU) are used for user policy.
- Merge: The user’s normal GPOs are applied, then the computer’s GPOs are applied, with computer’s GPOs taking precedence on conflicts.
⚠️ Important Considerations
- Loopback can cause unexpected results if not well documented. Users might wonder why their usual settings are missing.
- Be careful with security settings – a user could potentially escape restrictions if loopback is misconfigured.
- Loopback only affects user policy; computer policy is always applied normally.
4.6 Troubleshooting GPO Issues
🔍 Why GPO Troubleshooting Matters
Group Policy is powerful, but when it doesn't work as expected, it can lead to security gaps, inconsistent configurations, and frustrated users. Troubleshooting GPO issues is a critical skill for any Active Directory administrator. This section provides a systematic approach to diagnosing and resolving the most common GPO problems.
Imagine you're the facilities manager of a large office building. The building has automated systems for lighting, heating, and security (Group Policy). One day, the lights in one wing don't turn on at the scheduled time. You need to check: Is the schedule set correctly? Is the system receiving power? Is there a local override? Troubleshooting GPO is exactly like that – methodically checking each layer until you find the broken link.
📊 Quick Stats
- 70% of GPO issues are due to permissions or linking.
- 20% are replication-related.
- 10% are client-side problems.
🔍 Common GPO Problems (With Real-World Examples)
GPO issues generally fall into four categories. Here's how to recognize each:
| Category | Symptoms | Real-World Example |
|---|---|---|
| GPO not applying at all | Settings missing; gpresult shows GPO not listed. | A new password policy GPO was created but users can still use weak passwords. |
| Incorrect settings applied | Some settings work, others don't; or wrong values appear. | A GPO sets desktop wallpaper to company logo, but users see a different image. |
| Slow logon/startup | Users wait minutes to log on; boot times are excessive. | After deploying a software installation GPO, logon times increase from 30 seconds to 5 minutes. |
| Inconsistent application across users/computers | Some users get the policy, others don't; same OU but different results. | A drive mapping GPO works for half the sales team but not the other half. |
🛠️ Essential Troubleshooting Tools (Your Diagnostic Kit)
Every administrator should be proficient with these tools. Think of them as your medical instruments for diagnosing GPO health.
Shows the Resultant Set of Policy (RSoP) for a computer or user.
Key commands:
gpresult /r– Summary for current user/computer.gpresult /scope:computer /r– Computer policies only.gpresult /scope:user /r– User policies only.gpresult /h C:\report.html– Detailed HTML report.gpresult /s WS001 /r– Run against remote computer.
What to look for: Applied GPOs, denied GPOs (with reasons), and last time policy was applied.
The central management tool with built-in troubleshooting wizards.
Key features:
- Group Policy Results Wizard: Simulates applied policies for a target user/computer (like a remote gpresult).
- Group Policy Modeling Wizard: "What‑if" scenarios – e.g., what policies would apply if this user moved to a different OU?
- Status tab: Shows link status, security filtering, and WMI filtering at a glance.
GPO logs are in a specific location:
Applications and Services Logs → Microsoft → Windows → Group Policy → Operational
Key Event IDs:
- 4016: GPO processing started.
- 5016: GPO processing completed.
- 7016: Extension processing started.
- 1030: Failed to query GPO list (often SYSVOL access issue).
- 1055: Failed to apply GPO (security filtering problem).
GroupPolicy module cmdlets:
Get GPO report
Get-GPOReport -Name "Default Domain Policy" -ReportType HTML -Path C:\report.html
Get GPO permissions
Get-GPPermission -Name "Default Domain Policy" -All
Force remote update
Invoke-GPUpdate -Computer WS001 -Force
Test WMI filter
Get-WmiObject -Query "Select * from Win32_OperatingSystem WHERE Version like '10.%'"
Legacy graphical tool (still useful on older systems). Run rsop.msc to see a snapshot of currently applied policies.
Note: Deprecated but still present; use gpresult for modern troubleshooting.
For replication issues:
repadmin /replsummary # Check overall replication health
repadmin /showrepl # Detailed replication status
repadmin /syncall /AdeP # Force replication
dfsrdiag backlog /rgname:"Domain System Volume" /rfname:"" /srv:DC01
🔎 Step‑by‑Step Troubleshooting Flow (Follow This Order)
When a GPO isn't working as expected, follow this systematic process to identify the root cause. It's like a diagnostic flowchart:
-
Check the basics: Is the GPO linked and enabled?
- In GPMC, verify the GPO is linked to the correct site, domain, or OU.
- Check that the link is not disabled (red X on the link icon).
- Check that the GPO itself is enabled (right‑click → GPO Status). It can be set to "All settings disabled" or "Computer/User settings disabled".
-
Check security filtering: Who can read and apply?
- By default, "Authenticated Users" has Read and Apply Group Policy.
- If you changed security filtering, ensure the target computer (for computer policies) or user (for user policies) is included, and that they have both "Read" and "Apply Group Policy" permissions.
- Important: For computer policies, the computer account must have these permissions, not the user. For user policies, the user account must have them.
- If you restricted to a specific group, verify the computer/user is a member of that group.
-
Check WMI filtering (if any):
- If the GPO has a WMI filter, it might not apply if the client doesn't match the query.
- Test the filter on an affected client using PowerShell:
Get-WmiObject -Query "your query"orGet-CimInstance -Query "your query". - If the query returns nothing, the filter is preventing application.
-
Check inheritance blocking and enforcement:
- If the target OU has "Block inheritance", only GPOs linked to that OU and enforced GPOs from higher levels apply.
- If your GPO is not enforced and inheritance is blocked, it won't apply.
- Conversely, if your GPO is enforced but a lower‑level GPO also has conflicting settings, the enforced one wins.
-
Run gpresult on an affected client:
- Execute
gpresult /r(or/scope:computer//scope:user). - Look for the "Applied Group Policy Objects" list – is your GPO there?
- If not, check the "Denied GPOs" section – it will often give a reason (e.g., security filtering, WMI filter).
- Generate an HTML report with
gpresult /h report.htmlfor detailed analysis.
- Execute
-
Check client connectivity and DC availability:
- Ensure the client can resolve DNS and reach a domain controller (
nltest /dsgetdc:domain.com). - Check if the client is in the correct site (
nltest /dsgetsite). - If the client can't reach a DC, GPO won't apply.
- Ensure the client can resolve DNS and reach a domain controller (
-
Check GPO version mismatch (replication issues):
- In GPMC, view the GPO's "Domain" and "Sysvol" version columns. If they differ, replication is incomplete.
- On the client, you can check the cached version vs. the server version in Event Viewer.
- Force replication with
repadmin /syncalland verify withrepadmin /showrepl. - Check DFSR health for SYSVOL replication (
dfsrdiag backlog).
-
Check client-side extension (CSE) status:
- Some policies require specific CSEs (e.g., Folder Redirection, Group Policy Preferences).
- Check the list of CSEs in the registry:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions. - Ensure they are enabled and not blocked.
🧪 Common GPO Errors and Their Fixes (With Event IDs)
| Error / Symptom | Event ID(s) | Possible Cause | Fix |
|---|---|---|---|
| "The system cannot find the file specified" | 1030, 1054 | SYSVOL inaccessible or GPT folder missing for the GPO. | Check SYSVOL share permissions (everyone has read?). Ensure the GPO folder exists at \\domain\SYSVOL\domain\Policies\{GPO-GUID}. If missing, restore from backup or recreate GPO. |
| GPO not applied despite appearing in gpresult list | 1055 | Security filtering lacks "Apply Group Policy" permission. | Grant the affected user/computer "Apply Group Policy" permission on the GPO (along with "Read"). Use GPMC → Delegation tab. |
| GPO partially applied (some settings missing) | Various | Conflicting GPO with higher precedence; local policy override; loopback issues. | Use gpresult to see the winning GPO for each setting. Check link order and enforcement. If using loopback, verify mode (Replace vs Merge). |
| Slow logon/startup | N/A | Too many GPOs, large scripts, software installation packages, or slow network. | Consolidate GPOs (aim for <10 per user/computer). Move scripts to DFS. Enable asynchronous policy processing (Computer → Admin Templates → System → Group Policy → "Specify Group Policy processing order" – but careful). Use slow link detection settings. |
| GPO applied but settings revert after some time | N/A | Another GPO with higher precedence applying later; local user override; application resetting settings. | Check background refresh order. Use enforced on critical GPOs. For registry settings, ensure they are in the correct policy branch (Policies vs Preferences). |
| "Access denied" when editing GPO | N/A | Insufficient permissions on the GPO. | Delegate permissions via GPMC → Delegation tab. Grant "Edit settings" to appropriate users/groups. |
| GPO version mismatch across DCs | 1085, 1160 | Replication failure between DCs (either AD or SYSVOL). | Check AD replication with repadmin. Check DFSR replication for SYSVOL. Resolve replication conflicts. |
💻 Advanced Troubleshooting with PowerShell (Real Scripts)
Here are some ready‑to‑use PowerShell snippets for common GPO troubleshooting tasks:
1. Get all GPOs linked to a specific OU
Get-ADOrganizationalUnit -Filter 'Name -eq "Sales"' | ForEach-Object {
$ouDN = $_.DistinguishedName
Get-GPInheritance -Target $ouDN | Select-Object -ExpandProperty GpoLinks
}
2. Find which GPOs apply to a specific user (simulate)
Get-GPResultantSetOfPolicy -User "CONTOSO\jsmith" -ReportType Html -Path C:\jsmith.html
3. Check if a specific GPO is being filtered out by WMI
$gpo = Get-GPO -Name "MyGPO"
$wmiFilter = $gpo.WmiFilter
if ($wmiFilter) {
Write-Host "WMI Filter: $($wmiFilter.Name) - Query: $($wmiFilter.Query)"
}
4. List all GPOs with their versions and check for mismatches
Get-GPO -All | Select DisplayName, ID, @{n="DomainVer";e={$.DomainVersion}}, @{n="SysVolVer";e={$.SysvolVersion}} |
Where-Object { $.DomainVer -ne $.SysVolVer }
5. Force Group Policy update on multiple remote computers
$computers = Get-ADComputer -Filter {Name -like "WS*"} | Select -Expand Name
Invoke-Command -ComputerName $computers -ScriptBlock { gpupdate /force /target:computer }
6. Get GPO permissions and export to CSV
Get-GPO -All | ForEach-Object {
$gpo = $_.DisplayName
Get-GPPermission -Name $gpo -All | Select @{n="GPO";e={$gpo}}, Trustee, Permission
} | Export-Csv GPO_Permissions.csv -NoTypeInformation
📝 Best Practices to Prevent GPO Issues (Proactive Approach)
- Maintain a clear naming convention: e.g., "GPO_OU_Description" – so you know at a glance what a GPO does.
- Document every GPO: Use the "Comment" field in GPMC to describe purpose, linked locations, and last modified by.
- Use the Central Store for ADMX files: Ensures all admins see the same settings.
- Limit the number of GPOs per user/computer: Aim for fewer than 10; each GPO adds processing time.
- Test in a pilot OU first: Create a "Test" OU with representative users/computers, link new GPOs there, and verify before rolling out to production.
- Regularly review and clean up: Remove unused GPOs and unlinked GPOs. Use GPMC's "Starter GPOs" for templates.
- Back up GPOs frequently: Right‑click the Group Policy Objects container → Back Up All. Store backups securely.
- Monitor replication: Use tools like
repadminanddfsrdiagto ensure both AD and SYSVOL are healthy. - Enable logging on problematic clients: Temporarily set verbose logging via reg key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Diagnostics\GPSvcDebugLevelto 0x30002 (hex).
🏢 Real-World Troubleshooting Scenario: The Case of the Missing Drive Mapping
Problem: The Sales team in New York has a GPO that maps the S: drive to a file server. Some users get the drive, others don't. All users are in the same OU.
Troubleshooting steps:
- Ran
gpresult /ron a working and non‑working machine – both showed the GPO as applied. - Generated HTML reports (
gpresult /h) and compared – the non‑working machine showed the drive mapping setting but with a red "Access Denied" next to the network path. - Checked permissions on the file server share – the "Sales" group had read/write, but the users in question were not in the group (they were in a different "Sales-NY" group).
- The GPO used the "Sales" group for security filtering, but the affected users were not members – they were members of "Sales-NY".
- Fix: Added the "Sales-NY" group to the security filtering of the GPO, or added the group to the share permissions.
📋 Quick Troubleshooting Checklist (Print and Keep)
- ✅ Is the GPO linked to the right container?
- ✅ Is the link enabled? Is the GPO itself enabled?
- ✅ Does the security filter include the user/computer? (And do they have Apply permission?)
- ✅ If a WMI filter exists, does the client match the query?
- ✅ Is inheritance blocked on the target OU? If so, is the GPO enforced?
- ✅ On the client: run
gpresult /r– is the GPO listed? Any denied GPOs? - ✅ Check Event Viewer for GPO errors (Event IDs 1030, 1055, etc.).
- ✅ Verify client can reach a DC and DNS resolution works.
- ✅ Check GPO version across DCs – any mismatch?
- ✅ Test with a different user/computer in same OU to isolate.
🎯 Key Takeaways – 4.6 Troubleshooting GPO Issues
- Most GPO issues stem from linking, security filtering, WMI filtering, or inheritance problems – check these first.
gpresultis your best friend for seeing what actually applied and why something was denied.- Event Viewer (Group Policy Operational log) provides detailed error information.
- Replication issues can cause inconsistent GPO application – monitor AD and SYSVOL health.
- Always test GPO changes in a pilot OU before wide deployment.
- Document your GPOs and maintain a clean environment to reduce troubleshooting time.
📘 SEO Summary – Group Policy Troubleshooting
Group Policy troubleshooting is a critical skill for Windows administrators to resolve issues where GPOs don't apply correctly. Common problems include GPOs not applying, incorrect settings, slow logon, and inconsistent application across users/computers. Key tools include gpresult for Resultant Set of Policy (RSoP) analysis, GPMC for modeling and results, Event Viewer for error logs (Event IDs 1030, 1055, 4016), and PowerShell for automation. Systematic troubleshooting steps involve checking GPO linking, security filtering, WMI filtering, inheritance, client connectivity, and replication health. Best practices like maintaining a clear naming convention, using a Central Store for ADMX, testing in a pilot OU, and regular GPO backups prevent many issues. Mastering GPO troubleshooting ensures consistent configuration and security across an Active Directory domain.
🎓 Module 04 : Group Policy (GPO) Deep Dive Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 05 : DNS & Active Directory Replication
This module explores the critical relationship between DNS and Active Directory and the mechanics of replication that keep domain controllers synchronised. You will learn why DNS is the foundation of AD location services, how SRV records enable clients to find domain controllers, and how replication works across multi‑site environments. We cover the Knowledge Consistency Checker (KCC), replication topologies, and essential monitoring tools like repadmin and dcdiag. Mastering these concepts is vital for maintaining a healthy, high‑performance Active Directory infrastructure.
5.1 Why DNS is Critical for Active Directory
🌐 The Role of DNS in AD
Active Directory Domain Services (AD DS) is completely dependent on DNS. Without properly functioning DNS, clients cannot locate domain controllers, domain controllers cannot replicate with each other, and many essential services fail. AD uses DNS as its locator service, replacing the NetBIOS-based browsing of older Windows NT domains.
Think of DNS as the phonebook for Active Directory. When a client needs to find a domain controller, it looks up the number (IP address) in the phonebook (DNS). If the phonebook is missing or wrong, the client cannot call anyone.
🔍 How Clients Use DNS to Find Domain Controllers
When a domain‑joined computer starts up or a user logs on, the client must locate a domain controller for authentication. The process follows these steps:
- The client queries its configured DNS server for SRV records in the domain. Specifically, it looks for
_ldap._tcp.dc._msdcs.(e.g.,_ldap._tcp.dc._msdcs.contoso.com). - DNS returns a list of domain controllers (by hostname) that provide LDAP services for that domain.
- The client then performs an A/AAAA lookup for each hostname to obtain an IP address.
- The client contacts one of the returned domain controllers to begin authentication.
This process is defined in RFC 2782 (DNS SRV) and is essential for AD to function. If DNS is misconfigured, clients will fail to find a DC, resulting in logon delays, inability to apply Group Policy, and overall network issues.
📌 DNS Zones and Active Directory Integration
DNS zones can be stored in two ways:
- Standard primary/secondary zones: Text files stored on DNS servers; replication is not integrated with AD.
- Active Directory‑integrated zones: The zone data is stored in the Active Directory database (in the Domain or Forest DNS application partition). This provides several benefits:
- Multi‑master replication: Any domain controller that is also a DNS server can accept updates.
- Secure dynamic updates: Only authenticated computers can update their records.
- Automatic replication: Zone data replicates along with AD, simplifying management.
- No single point of failure: If one DNS server fails, others continue to serve the zone.
For maximum reliability, it is strongly recommended to configure DNS zones as Active Directory‑integrated on all domain controllers that run the DNS Server role.
🔧 DNS Requirements for AD DS
Before promoting a server to a domain controller, you must ensure DNS is properly configured. Key requirements:
- DNS name resolution: The server must be able to resolve the domain name and locate other domain controllers.
- SRV record support: The DNS server must support SRV records (most modern DNS servers do).
- Dynamic updates: For clients to register their own records, the zone should allow dynamic updates (preferably secure).
- Delegation: If you are creating a child domain, the parent DNS zone must have delegation records pointing to the child’s DNS servers.
🛠️ Common DNS Issues in AD
- Missing SRV records: Domain controllers register SRV records automatically, but if dynamic updates are disabled or the records are deleted, clients cannot find DCs. Rebuild them by restarting the NetLogon service on the DC or using
nltest /dsregdns. - Stale records: Old records for decommissioned DCs can cause clients to attempt connections to non‑existent servers. Regularly scavenge DNS.
- Incorrect DNS server settings on clients: Clients must point to internal DNS servers that can resolve AD domains, not external DNS like 8.8.8.8.
- Replication lag: If a new DC is added but its DNS records haven’t replicated to all DNS servers, some clients may not see it.
5.2 SRV Records Explained
📋 What Are SRV Records?
Service (SRV) records are DNS resource records that specify the location of services. In Active Directory, SRV records tell clients which servers provide specific services for a domain, such as LDAP, Kerberos, and Global Catalog. They follow the format:
_service._protocol.domain TTL class SRV priority weight port target
For example:
_ldap._tcp.dc._msdcs.contoso.com 600 IN SRV 0 100 389 dc1.contoso.com
🧩 Important SRV Records in AD
Domain controllers register several SRV records automatically. The most important are:
| Service | SRV Record Format | Purpose |
|---|---|---|
| LDAP (Domain Controller) | _ldap._tcp.dc._msdcs. | General domain controller discovery for LDAP authentication. |
| Kerberos | _kerberos._tcp. and _kerberos._udp. | Locate Kerberos Key Distribution Centers (KDCs). |
| Global Catalog | _ldap._tcp.gc._msdcs. | Find Global Catalog servers for forest‑wide searches. |
| Domain Controller by Site | _ldap._tcp. | Clients can request DCs in a specific site for optimal performance. |
| PDC Emulator | _ldap._tcp.pdc._msdcs. | Locate the Primary Domain Controller emulator for time sync and password changes. |
| Kerberos Password Change | _kpasswd._tcp. and _kpasswd._udp. | Locate Kerberos password change servers. |
🔍 How SRV Records Are Registered
When a domain controller starts, the NetLogon service registers its SRV records via dynamic DNS. The records are stored in the DNS zone(s) corresponding to the domain and forest. The registration includes:
- Priority and weight: Used for load balancing. Lower priority is preferred; among same priority, higher weight is chosen more often.
- Port: Typically 389 for LDAP, 88 for Kerberos, 3268 for Global Catalog.
- Target: The FQDN of the domain controller.
If a domain controller is also a Global Catalog server, it registers records in the gc._msdcs subdomain. For site awareness, it registers records in subdomains based on its subnet membership.
🛠️ Verifying and Troubleshooting SRV Records
Use the following tools to check SRV records:
nslookup: Set type=SRV and query_ldap._tcp.dc._msdcs.contoso.com.dnscmd:dnscmd /enumrecords._msdcs netdiag(older) ordcdiag /test:dns: Comprehensive DNS tests.- PowerShell:
Resolve-DnsName -Name "_ldap._tcp.dc._msdcs.contoso.com" -Type SRV.
If SRV records are missing, try:
- Restarting the NetLogon service on the DC (reregisters all SRV records).
- Running
nltest /dsregdnsto force registration. - Checking that the DNS zone allows dynamic updates and that the DC has permissions.
- Manually adding records (temporary fix; better to fix dynamic registration).
📁 SRV Records and Site Awareness
Clients can request domain controllers in a specific site by querying _ldap._tcp.. For this to work, the DC must be associated with a site via its subnet, and it must have registered the site‑specific SRV record. This is how clients ensure they contact a local DC, reducing authentication latency.
5.3 Multi‑Site AD Replication
🌍 What is Multi‑Site Replication?
In a multi‑site Active Directory environment, domain controllers are located in different physical locations (sites). Replication between sites must be managed carefully to optimise network bandwidth and ensure data consistency. AD uses a site topology to control replication flow.
🏢 Sites and Subnets
- Sites: Represent physical locations with good network connectivity (typically LAN speed). Sites are defined in Active Directory Sites and Services.
- Subnets: IP address ranges assigned to a site. When a client or DC’s IP falls within a subnet, it is associated with that site.
The primary purpose of sites is to:
- Direct clients to the nearest domain controller (site awareness).
- Optimise replication traffic between domain controllers.
🔄 Intra‑Site vs Inter‑Site Replication
- Intra‑site replication (within a site): Occurs frequently (every 15 seconds by default) and uses a notify‑push model. When a change occurs on a DC, it notifies its partners, and they pull the changes. Replication is not compressed.
- Inter‑site replication (between sites): Occurs according to a schedule (default every 180 minutes) and uses a pull model. Data can be compressed to save bandwidth (compressible by default). The schedule can be configured to occur during off‑peak hours.
🔗 Site Links and Costs
Site links connect two or more sites and define the replication path. Key properties:
- Cost: An arbitrary value (default 100) used to determine the preferred path. Lower cost is preferred.
- Replication interval: How often replication occurs (minimum 15 minutes, default 180).
- Schedule: When replication is allowed (e.g., only during business hours).
- Transport: IP (RPC over IP) or SMTP (rarely used). IP is the standard.
The Knowledge Consistency Checker (KCC) uses site link costs to build a least‑cost spanning tree for replication between sites. If multiple links exist, the KCC chooses the lowest cumulative cost path.
🧩 Bridgehead Servers
Inter‑site replication is performed by bridgehead servers – one per site, per directory partition, per transport. The KCC automatically selects a preferred bridgehead (or you can designate a preferred one). The bridgehead is responsible for sending and receiving replication data from other sites, reducing the replication burden on all DCs in the site.
If the bridgehead fails, the KCC will automatically promote another DC to act as bridgehead (unless you’ve configured manual preferences).
📦 Replication Protocols
- RPC over IP: Default for both intra‑site and inter‑site. Uses remote procedure calls. For inter‑site, it can be compressed.
- SMTP: Deprecated and rarely used; requires a certification authority and only replicates the configuration, schema, and application partitions (not domain partition).
⏱️ Replication Latency and Urgent Replication
In a multi‑site environment, changes may take time to replicate (site link interval). However, certain changes are considered urgent and replicate immediately (within 15 seconds) even across sites:
- Account lockouts.
- Password changes (when a user changes their password, the change is sent immediately to the PDC emulator; other DCs get it via normal replication).
- Changes to the LSA‑Secret (trusted domain objects).
- RID pool updates.
Urgent replication helps prevent security issues (like a user being locked out but still able to authenticate due to replication delay).
5.4 Replication Topology
🔁 The Knowledge Consistency Checker (KCC)
The Knowledge Consistency Checker (KCC) is a built‑in process that runs on every domain controller. Its job is to automatically generate and maintain the replication topology – both within a site and between sites. The KCC ensures that every directory partition is replicated to all DCs that need it, using a minimum number of connections while maintaining fault tolerance.
🧩 Intra‑Site Topology
Within a site, the KCC creates a ring topology where each DC has at least two inbound connections (for redundancy). The default intra‑site topology ensures that if one DC fails, replication can still flow through another path. The KCC reevaluates the topology every 15 minutes (configurable) and adjusts if DCs are added or removed.
The intra‑site replication connections are two‑way and use a notify‑push mechanism: when a DC has changes, it notifies its replication partners, who then pull the changes.
🌍 Inter‑Site Topology
For inter‑site replication, the KCC on the bridgehead servers in each site communicate to build a spanning tree based on site link costs. One KCC (in one site) is designated as the Inter‑Site Topology Generator (ISTG) for each site. The ISTG is responsible for calculating the inter‑site topology and telling other bridgeheads about it.
- ISTG: By default, the first DC in a site becomes the ISTG. If it fails, another takes over.
- The ISTG ensures that there is a replication path between every site that hosts a given directory partition.
🔌 Connection Objects
The KCC creates connection objects in the Active Directory configuration partition (CN=NTDS Settings,CN=). These objects define from which source a DC should replicate. Administrators can manually create connection objects, but it’s rarely necessary; the KCC’s automatic connections are sufficient. If you manually create connections, they may be overwritten unless you set a specific flag.
🔍 Replication Topology Example
Consider a forest with two sites (SiteA and SiteB), each with two DCs. The KCC in SiteA builds an intra‑site ring between its two DCs. Similarly in SiteB. The ISTG (say in SiteA) creates a site link between SiteA and SiteB. It then creates connection objects on the bridgehead in SiteA to replicate from the bridgehead in SiteB, and vice versa. The bridgeheads then replicate changes to their intra‑site partners.
SiteA:
DC1 ←→ DC2 (intra‑site connections)
DC1 (bridgehead) ←→ DC3 (bridgehead in SiteB) (inter‑site connection)
SiteB:
DC3 ←→ DC4 (intra‑site connections)
🛠️ Viewing and Modifying Topology
- Active Directory Sites and Services: Expand a site, then servers, then NTDS Settings to see inbound connection objects.
repadmin /showconn: Displays all connection objects for a DC.repadmin /kcc: Forces the KCC to recalculate the topology immediately.- PowerShell:
Get-ADReplicationConnection -Filter *.
5.5 Monitoring Replication Health
🔍 Why Monitor Replication?
Replication is the heartbeat of Active Directory. If replication fails, domain controllers become inconsistent, leading to authentication failures, policy conflicts, and potential data loss. Regular monitoring ensures that all DCs are synchronised and that the topology is functioning correctly.
🛠️ Essential Tools for Replication Monitoring
repadmin: The primary command‑line tool for diagnosing replication. It comes with Remote Server Administration Tools (RSAT). Key commands:repadmin /replsummary– Summarises replication status across all DCs.repadmin /showrepl– Shows detailed replication status per DC.repadmin /queue– Displays pending replication operations.repadmin /syncall– Forces replication between DCs.repadmin /failcache– Shows failed replication attempts.
dcdiag: Comprehensive domain controller health checker. Tests include:/test:Replications– Checks replication status./test:Topology– Validates the KCC topology./test:Intersite– Checks inter‑site health.
- Event Viewer: Look for replication‑related events in:
- Directory Service log (Event ID 1311, 1864, 1988, 2042, etc.)
- DFS Replication log (for SYSVOL)
- PowerShell:
Get-ADReplicationFailure,Get-ADReplicationPartnerMetadata, etc. - Active Directory Replication Status Tool (a GUI tool from Microsoft).
📊 Key Replication Metrics
- USN (Update Sequence Number): Each DC tracks changes with USNs. Replication partners compare USNs to know what changes to request.
- High Watermark and UpToDateness Vector: Used to track the latest changes a DC has received from each source.
- Replication latency: Time taken for a change to appear on all DCs.
⚠️ Common Replication Errors and Their Fixes
| Error/Symptom | Possible Cause | Fix |
|---|---|---|
| Event ID 2042: “It has been too long since this machine replicated…” | A DC has been offline for longer than the tombstone lifetime (default 180 days). It is now in a “lingering object” state. | Remove the DC from the domain, perform metadata cleanup, and re‑promote. Or use repadmin /removelingeringobjects if safe. |
| Event ID 1925: “Failed to establish a replication link…” | Network connectivity, DNS, or firewall issues blocking replication. | Check connectivity (ping, ports 135, 389, 636, 3268, 445, 49152‑65535 for RPC). Verify DNS resolution. |
| Event ID 1988: “The local domain controller has attempted to replicate an object… that does not exist on the source.” | Lingering objects. | Use repadmin /removelingeringobjects on the source DC. |
| Event ID 1311: “The Knowledge Consistency Checker was unable to form a spanning tree.” | Site link misconfiguration (e.g., all site links disconnected). | Review site links, ensure every site is connected via at least one link. |
| Event ID 1864: “This domain controller is unable to replicate because of too many errors.” | Persistent replication failures. | Run dcdiag /test:Replications and fix underlying issues. |
| Slow replication / high latency | Network congestion, long site link intervals, or high cost paths. | Adjust site link schedules, add new site links, or increase bandwidth. |
📝 Using repadmin – Examples
# Summarise replication across the forest
repadmin /replsummary
# Show detailed replication status for a specific DC
repadmin /showrepl DC01.contoso.com
# Force replication of a specific directory partition
repadmin /syncall /e /A /P /d /q
# Check replication queue (pending changes)
repadmin /queue DC01.contoso.com
# Show replication failures in the last 3 days
repadmin /failcache *
# Remove lingering objects (use with caution)
repadmin /removelingeringobjects DC01.contoso.com DC=contoso,DC=com /advisory_mode
📈 Proactive Replication Monitoring
- Set up monitoring alerts for Event IDs 1925, 1988, 2042, 1311, and 1864.
- Run
repadmin /replsummarydaily via a scheduled task and report any failures. - Use System Center Operations Manager (SCOM) or third‑party tools to monitor replication health.
- Regularly review the number of lingering objects with
repadmin /removelingeringobjects * /advisory_mode. - Monitor replication latency by comparing timestamps on changes across DCs.
🔐 Best Practices for Healthy Replication
- Maintain at least two DCs per domain for redundancy.
- Ensure all DCs have accurate time sync (use the PDC emulator as the time source).
- Keep the tombstone lifetime at its default (180 days) and never set it lower without understanding the consequences.
- Regularly back up at least one DC per domain.
- Monitor and maintain DNS health (see 5.1).
- Keep replication schedules realistic; avoid setting intervals too short for slow WAN links.
Replication issues are among the most common causes of Active Directory failures. Proactive monitoring with
repadmin and dcdiag can catch problems before they affect users.
🎓 Module 05 : DNS & AD Replication Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 06 : Active Directory Security Hardening
This module provides an in‑depth exploration of Active Directory security, covering the authentication protocols that underpin AD, the evolution from NTLM to Kerberos, and the principles of least privilege. You will learn how to protect administrative accounts, understand common attack techniques like Pass‑the‑Hash and Golden Ticket, and implement hardening and monitoring best practices. Securing AD is critical because it is the identity store for the entire organisation – a compromised AD means a compromised enterprise.
6.1 Kerberos Authentication Explained
🔑 What is Kerberos?
Kerberos is a network authentication protocol designed to provide strong authentication for client/server applications using secret‑key cryptography. It is the default authentication protocol in modern Active Directory domains. Kerberos was developed at MIT and named after the three‑headed dog of Greek mythology – fitting because it uses three parties: the client, the server, and a trusted third party (the Key Distribution Center).
In Active Directory, Kerberos is the foundation of secure authentication. It enables single sign‑on (SSO), mutual authentication, and reduced network exposure of credentials. Unlike older protocols such as NTLM, Kerberos never transmits passwords or password hashes over the network; instead, it uses tickets and session keys to prove identity.
Kerberos works like a hotel key card system. You check in at the front desk (Authentication Server), get a master key (Ticket Granting Ticket), and then use that master key to get room‑specific keys (Service Tickets) from a special machine (Ticket Granting Service). You never show your ID again; you just show the appropriate key.
🧩 Components of Kerberos
- KDC (Key Distribution Center): In Active Directory, every domain controller runs a KDC. It has two logical components:
- Authentication Service (AS): Issues Ticket Granting Tickets (TGTs) after verifying the client’s identity.
- Ticket Granting Service (TGS): Issues Service Tickets (STs) for specific services, based on a valid TGT.
- Principal: A unique identity such as a user, computer, or service. Each principal has a long‑term secret – typically a password (for users) or a computer account password (for machines).
- Ticket Granting Ticket (TGT): A credential that proves the client has been authenticated. It contains the client’s identity, a session key, and an expiration time. The TGT is encrypted with the KDC’s own key (the KRBTGT account’s key).
- Service Ticket (ST): A ticket that allows a client to authenticate to a specific service. It contains the client’s identity, a session key (different from the TGT session key), and is encrypted with the target service’s long‑term key.
- Authenticator: A timestamp encrypted with the session key. It proves that the client possesses the session key and that the message is recent (replay protection).
- Session Key: A temporary key generated by the KDC and used to encrypt communications between the client and the KDC, or between the client and a service. Session keys are short‑lived and never reused.
🔄 The Kerberos Authentication Flow (Detailed)
The Kerberos protocol consists of three main message exchanges, often called the “Kerberos 3‑legged dog”. We’ll explore each step in depth, including the contents of the messages.
1. AS Exchange (Authentication Service)
The goal of the AS exchange is for the client to obtain a TGT.
- AS‑REQ (Client → KDC): The client sends an authentication request to the KDC’s Authentication Service. It includes:
- The client’s principal name (e.g.,
user@REALM). - A timestamp encrypted with the client’s long‑term key (derived from the password). This is the pre‑authentication data (see below).
- Optionally, the requested ticket lifetime and encryption types supported.
- The client’s principal name (e.g.,
- KDC processing: The KDC looks up the client’s key in its database (Active Directory). It decrypts the pre‑authentication timestamp and verifies that it is recent (within a few minutes). If successful, the KDC knows the client is genuine.
- AS‑REP (KDC → Client): The KDC responds with:
- A TGT, encrypted with the KDC’s own key (the KRBTGT account’s key). The TGT contains the client’s identity, a new session key (
SK_TGT), the ticket lifetime, and other attributes. Because it’s encrypted with the KDC’s key, the client cannot read it, but it will store it. - The same session key (
SK_TGT) is also encrypted separately with the client’s long‑term key, so the client can decrypt it.
- A TGT, encrypted with the KDC’s own key (the KRBTGT account’s key). The TGT contains the client’s identity, a new session key (
- Client processing: The client uses its long‑term key (derived from its password) to decrypt the session key
SK_TGT. It stores this session key and the TGT in its ticket cache (memory). The TGT itself remains opaque to the client.
2. TGS Exchange (Ticket Granting Service)
When the client wants to access a service (e.g., a file server), it must obtain a Service Ticket (ST) for that service.
- TGS‑REQ (Client → KDC): The client sends a request to the Ticket Granting Service. It includes:
- The TGT (still encrypted with the KDC’s key).
- An authenticator encrypted with the session key
SK_TGT. This proves the client possesses the session key. - The Service Principal Name (SPN) of the target service (e.g.,
cifs/fileserver.contoso.com). - Optionally, requested options (e.g., delegation, renewable).
- KDC processing: The KDC decrypts the TGT using its own key, extracts
SK_TGT, and uses it to verify the authenticator. It then checks whether the client is authorized to access the requested service (by looking up the service’s account and any access controls). If all is well, it generates a Service Ticket (ST) for that service. The ST contains:- The client’s identity.
- A new session key (
SK_Service). - The ticket lifetime and other attributes.
- TGS‑REP (KDC → Client): The KDC returns:
- The Service Ticket (encrypted with the service’s key).
- The new session key
SK_Serviceencrypted withSK_TGT.
- Client processing: The client decrypts
SK_ServiceusingSK_TGTand stores it. It now has a valid Service Ticket for the target service.
3. AP Exchange (Client‑Service Authentication)
- AP‑REQ (Client → Service): The client sends the Service Ticket (still encrypted with the service’s key) along with a new authenticator encrypted with
SK_Serviceto the target service. - Service processing: The service decrypts the Service Ticket using its own long‑term key, extracting
SK_Serviceand the client’s identity. It then usesSK_Serviceto verify the authenticator. If successful, the service knows the client is authentic and that the ticket is fresh. - AP‑REP (optional, Service → Client): The service may send back an authenticator encrypted with
SK_Serviceto provide mutual authentication, proving that the service also possesses the correct key.
From this point onward, the client and service can communicate securely, optionally using the session key SK_Service to sign or encrypt application data.
🔐 Kerberos Pre‑Authentication
The initial AS‑REQ includes pre‑authentication data – typically a timestamp encrypted with the client’s long‑term key. This prevents an attacker from requesting a TGT for another user and then offline‑cracking the response. Without pre‑authentication, an attacker could request a TGT for any user and receive an encrypted TGT (which includes an encrypted session key) that could be cracked offline. This is the basis of the AS‑REP Roasting attack. In modern Active Directory, pre‑authentication is enabled by default for all user accounts. You can enforce it via Group Policy or on individual accounts.
Pre‑authentication can also use other mechanisms, such as public key cryptography (PKINIT), which uses certificates instead of passwords for the initial authentication.
🔑 Encryption Types and Keys
Kerberos supports multiple encryption types. The most important are:
- RC4‑HMAC (old, weak): Based on the MD4 hash of the password. Used for backward compatibility but vulnerable to attacks (e.g., pass‑the‑hash).
- AES128‑CTS‑HMAC‑SHA1 and AES256‑CTS‑HMAC‑SHA1 (strong): Modern encryption types, recommended. They are more secure and resistant to many attacks.
- DES (deprecated): No longer used in modern Windows.
The KDC and client negotiate the highest common encryption type. The domain functional level and Group Policy can restrict allowed encryption types. For best security, disable RC4 and require AES. This is done via Group Policy under Computer Configuration → Policies → Windows Settings → Security Settings → Local Policies → Security Options → “Network security: Configure encryption types allowed for Kerberos”.
Each principal has a long‑term key derived from its password. For RC4, the key is the MD4 hash of the password. For AES, it’s derived using a PBKDF2 function. The KRBTGT account’s key is used to encrypt all TGTs – which is why the KRBTGT hash is the most sensitive secret in the domain.
🎫 Ticket Structure
A Kerberos ticket (TGT or ST) is not just a blob; it contains several fields:
- Ticket version number (5 for Kerberos 5).
- Realm – the domain that issued the ticket.
- Principal name – the client’s identity.
- Encrypted part – contains the session key, the client’s attributes, flags, start time, end time, renewal time, and authorization data (such as group memberships). This part is encrypted with the target’s key (KDC key for TGT, service key for ST).
The authorization data in a service ticket can include PAC (Privilege Attribute Certificate). The PAC contains the user’s security identifier (SID), group memberships, and other authorization information. The service uses this to build the user’s access token. The PAC is signed by the KDC to prevent tampering.
🌍 Cross‑Realm Authentication (Trusts)
Kerberos supports authentication across realms (domains/forests) through cross‑realm trusts. When a client in Realm A wants to access a service in Realm B, the KDC in Realm A issues a referral ticket for Realm B’s KDC, and the client then requests a service ticket from Realm B’s KDC. This relies on a shared inter‑realm key (the trust password) between the two KDCs.
In Active Directory, domain trusts (parent‑child, tree, forest, shortcut, external) automatically establish the necessary Kerberos trust relationships. For example, a user in a child domain can access a file server in the parent domain using Kerberos because the KDCs forward referrals using the trust key.
🔄 Kerberos Delegation
Delegation allows a service to act on behalf of a user when accessing other services. For example, a web server may need to access a database server using the user’s identity. Kerberos supports three types of delegation:
- Unconstrained delegation: The service can impersonate the user to any other service. This is dangerous because the service’s TGT (if forwarded) can be used anywhere. It should be avoided.
- Constrained delegation: The service is allowed to delegate only to specific services (using S4U2Proxy). This is more secure.
- Resource‑based constrained delegation: Introduced in Windows Server 2012, the target service controls which accounts are trusted for delegation. This is even more secure and easier to manage.
Delegation requires the user account to be trusted for delegation (the “Trust this user for delegation to specified services only” option in ADUC) and appropriate SPN configuration.
⏲️ Time Synchronization
Kerberos is extremely time‑sensitive. It relies on timestamps in authenticators to prevent replay attacks. By default, the maximum allowable time skew between a client and a KDC is 5 minutes. If clocks differ by more than this, authentication fails. In Active Directory, all domain members synchronize time with the domain controller hierarchy, with the PDC Emulator acting as the authoritative time source. Ensure time sync is working to avoid Kerberos errors.
🛡️ Security Considerations and Best Practices
- Enable AES encryption: Disable RC4 if possible to prevent attacks like Kerberoasting (which often targets RC4‑encrypted tickets).
- Protect the KRBTGT account: Regularly rotate its password (twice, with a delay) to invalidate any forged Golden Tickets.
- Use Managed Service Accounts (MSAs) / Group MSAs: These have automatic password rotation and long complex passwords, making Kerberoasting harder.
- Enable Kerberos armoring (FAST): Introduced in Windows Server 2012, Kerberos armoring protects the TGS exchange by using the TGT session key to encrypt the TGS request. This prevents offline cracking of service tickets.
- Monitor for anomalous Kerberos events: Event IDs 4768 (TGT requested), 4769 (ST requested), 4771 (pre‑auth failed), 4770 (TGT renewed). Look for unusual patterns (e.g., many requests for a service account).
- Set appropriate ticket lifetimes: Shorter lifetimes reduce the window for ticket theft. Use Group Policy to adjust “Maximum lifetime for service ticket” and “Maximum lifetime for user ticket”.
- Enforce pre‑authentication: Ensure all user accounts have “Do not require Kerberos preauthentication” unchecked (except for special cases like some UNIX integrations).
- Use constrained delegation: Avoid unconstrained delegation. Review delegation settings regularly.
📊 Kerberos Message Types Summary
| Message | Direction | Purpose |
|---|---|---|
| AS‑REQ | Client → KDC (AS) | Request TGT |
| AS‑REP | KDC (AS) → Client | Return TGT |
| TGS‑REQ | Client → KDC (TGS) | Request Service Ticket |
| TGS‑REP | KDC (TGS) → Client | Return Service Ticket |
| AP‑REQ | Client → Service | Present Service Ticket |
| AP‑REP | Service → Client | Mutual authentication |
| KRB‑ERROR | Any | Error response |
6.2 NTLM vs Kerberos – Deep Dive Comparison
🔄 NTLM (NT LAN Manager) – The Legacy Protocol
NTLM is a family of authentication protocols developed by Microsoft and used in Windows operating systems. It evolved through several versions: NTLMv1 (introduced with Windows NT 3.5), NTLMv2 (introduced with Windows NT 4.0 SP4), and the NTLM2 Session variant. While largely superseded by Kerberos in domain environments, NTLM remains widely supported for backward compatibility, particularly with standalone systems, down‑level clients, and legacy applications.
How NTLM Works – Detailed Technical Flow:
- Negotiation: The client sends a Negotiate message to the server, listing its supported NTLM version and features.
- Challenge: The server responds with a Challenge message containing an 8‑byte random number (the nonce) for NTLMv1, or a more complex challenge for NTLMv2 that includes a timestamp and server name.
- Authentication: The client computes a response by:
- Hashing the user’s password (using MD4 for NTLMv1, HMAC‑MD5 for NTLMv2).
- Using that hash to encrypt the challenge (or a derivative) – creating the LM Response (weak) and NT Response (stronger). NTLMv2 creates a more complex response that includes a client nonce and timestamp to prevent replay attacks.
- Sending the responses back to the server.
- Verification: The server forwards the challenge and response to a domain controller (or verifies locally if it’s a local account). The DC looks up the user’s password hash from the SAM or Active Directory, recomputes the expected response, and compares. If they match, authentication succeeds.
- Result: The DC informs the server, which then grants or denies access.
NTLMv2 is a significant improvement over NTLMv1, using stronger cryptography and including a timestamp to mitigate replay attacks. However, it still lacks mutual authentication and is vulnerable to pass‑the‑hash and relay attacks if not properly secured.
🔑 Kerberos – The Modern Standard
As detailed in section 6.1, Kerberos is the default authentication protocol for Active Directory. It provides mutual authentication, supports delegation, and never transmits password hashes. It relies on tickets issued by a trusted Key Distribution Center (KDC) and uses symmetric key cryptography. Kerberos is far more secure and feature‑rich than NTLM, but it requires a properly configured domain infrastructure and time synchronisation.
🔍 Head‑to‑Head Comparison – Expanded
| Feature | Kerberos | NTLM |
|---|---|---|
| Authentication Type | Ticket‑based using symmetric keys and a trusted third party (KDC). | Challenge‑response using password hashes (no third party in local case, but domain controller used for domain accounts). |
| Mutual Authentication | Yes – client verifies server identity via the service ticket; server verifies client via authenticator. | No – only server verifies client; client cannot verify server’s identity (vulnerable to man‑in‑the‑middle). |
| Credential Exposure | Password hash never sent over network; only tickets (encrypted) and session keys. | Password hash is used to encrypt challenge; the response contains proof of knowledge, but hash is not directly sent. However, the NetNTLM hash can be captured and relayed. |
| Delegation / Impersonation | Supports constrained and unconstrained delegation (service can act on behalf of user). | No native delegation; double‑hop requires pass‑through authentication (often fails). |
| Session Security | Can generate session keys for signing and encryption of application data. | Limited; relies on other mechanisms like SMB signing for integrity. |
| Scalability & Performance | Excellent – tickets are cached, reducing load on DCs after initial authentication. | Each authentication may require contact with DC; no caching of authentication proof. |
| Protocol Vulnerabilities | Golden Ticket (if KRBTGT stolen), Silver Ticket, Kerberoasting, AS‑REP Roasting, delegation abuse. Generally requires high privileges to execute. | Pass‑the‑Hash, NTLM relay, brute‑force (especially NTLMv1), reflection attacks. Often easier for attackers to exploit from a low‑privileged position. |
| Dependencies | Requires domain environment, DNS, time sync (max 5 min skew), and SPNs for services. | Works in workgroups and domains; no strict time or DNS requirements. |
| Protocol Default | Default for domain‑joined machines and services in Active Directory. | Fallback when Kerberos fails; default for local accounts, IP address connections, and non‑domain scenarios. |
📊 When NTLM Is Used – Detailed Scenarios
- Authentication using IP addresses instead of hostnames: Kerberos tickets are issued to SPNs, which are tied to hostnames. If a client connects to a server using its IP address (e.g.,
\\192.168.1.10\share), it cannot request a ticket for that IP because no SPN exists. NTLM is used as a fallback. - Accessing resources on non‑domain‑joined machines: Kerberos requires a domain trust. If the target server is in a workgroup, Kerberos cannot be used.
- Applications that hard‑code NTLM usage: Some legacy applications (e.g., older versions of SQL Server, custom in‑house apps) may only support NTLM.
- Authentication to down‑level operating systems: Windows NT 4.0 and earlier do not support Kerberos.
- Double‑hop without Kerberos delegation configured: For example, a web server (IIS) with Windows authentication attempting to access a remote SQL server using the user’s credentials. If Kerberos delegation is not set up, the double‑hop fails and may fall back to NTLM (if the service account permissions allow).
- Network connectivity issues to KDC: If a client cannot reach a domain controller (e.g., VPN disconnected, network outage), Kerberos fails and the client may attempt NTLM.
- Missing or misconfigured SPNs: If a service’s SPN is not registered correctly, clients cannot request a Kerberos ticket and fall back to NTLM.
- Anonymous authentication or guest access: Some anonymous connections may use NTLM.
🛡️ NTLM Attack Surface – In Depth
NTLM’s weaknesses have led to numerous attack techniques that are staples in penetration testing and real‑world breaches:
- Pass‑the‑Hash (PtH): An attacker extracts the NTLM hash of a user (from LSASS memory or a compromised system) and uses it to authenticate to other systems. Since NTLM uses the hash directly as the authentication secret, having the hash is equivalent to having the password. Mitigation: Use Kerberos, enable Credential Guard, use Protected Users group, and restrict NTLM.
- NTLM Relay: An attacker intercepts an NTLM authentication attempt and forwards (relays) it to another server, authenticating as the victim. This is especially dangerous when combined with protocols like SMB and HTTP. Mitigation: Enable SMB signing, require LDAP signing, use EPA (Extended Protection for Authentication), and disable NTLM where possible.
- LLMNR/NBT‑NS Poisoning: When a client fails to resolve a hostname via DNS, it broadcasts a request using LLMNR or NetBIOS. An attacker on the same subnet can respond, tricking the client into sending NTLM authentication to the attacker’s machine. The attacker can then crack the hash or relay it. Mitigation: Disable LLMNR and NetBIOS via Group Policy, and enforce SMB signing.
- NTLMv1 Downgrade: An attacker can force a client to use the weaker NTLMv1 protocol, which is vulnerable to offline cracking (e.g., using rainbow tables). Mitigation: Disable NTLMv1 entirely via Group Policy and network security settings.
- Offline Cracking: Captured NTLMv2 responses can be cracked offline (using tools like Hashcat) to recover the plaintext password, especially if the password is weak. Strong password policies help mitigate this.
🔧 Detailed NTLM Hardening and Migration Strategies
Moving away from NTLM requires a phased approach. Here’s a step‑by‑step guide:
- Audit NTLM Usage: Enable auditing via Group Policy to identify which applications, servers, and clients are using NTLM. Use the following policies:
Network security: Restrict NTLM: Audit Incoming NTLM traffic– set to “Enable auditing for all accounts”.Network security: Restrict NTLM: Audit NTLM authentication in this domain– set to “Enable all”.- Monitor Event IDs 8001, 8002, 8003, 8004 (NTLM authentication events) in the “Microsoft-Windows-NTLM/Operational” log.
- Fix Kerberos Issues: Many NTLM fallbacks are due to missing SPNs. Ensure all critical services have proper SPNs registered. Use
setspnto list and verify. Also ensure DNS is healthy. - Enable NTLMv2 and Reject v1: Set
Network security: LAN Manager authentication levelto “Send NTLMv2 response only. Refuse LM & NTLM”. This disables the older, weaker protocols. - Require NTLMv2 Session Security: Enable “Network security: Minimum session security for NTLM SSP based (clients/servers)” to require 128‑bit encryption and NTLMv2 session security.
- Restrict NTLM by Policy: Move from audit to restrict:
- Set
Network security: Restrict NTLM: Incoming NTLM trafficto “Deny all domain accounts” or “Deny all accounts”. - Set
Network security: Restrict NTLM: Outgoing NTLM traffic to remote serversto “Deny all” or “Deny all domain accounts”. - Use exceptions lists for servers that still require NTLM (e.g., “Allow server exceptions”).
- Set
- Implement SMB Signing: For all systems, enable SMB signing (at least for domain controllers). This prevents NTLM relay attacks. Policy:
Microsoft network server: Digitally sign communications (always)andMicrosoft network client: Digitally sign communications (always). - Disable LLMNR and NetBIOS over TCP/IP: Via Group Policy (Computer Configuration → Administrative Templates → Network → DNS Client) and network adapter settings.
- Migrate Applications: Work with application owners to update or replace legacy applications that require NTLM. For .NET applications, consider using
System.Net.Kerberosor configuring SPNs.
🧪 Testing and Validation
After hardening, validate that NTLM usage has dropped and that critical services still function:
- Use
kliston clients to view Kerberos tickets. - Use
nltest /dsgetdc:to ensure DC discovery. - Monitor Event Logs for NTLM rejections (Event ID 8005).
- Perform application testing for all critical line‑of‑business applications.
📈 Comparison of Security Posture
| Configuration | NTLM Security Level | Risk Mitigation |
|---|---|---|
| Default (NTLMv1/v2 enabled, no signing) | Low | Vulnerable to PtH, relay, cracking, poisoning |
| NTLMv2 only, SMB signing enabled | Medium | Reduces risk of relay, prevents v1 attacks |
| NTLM restricted (audit mode) | Medium‑High | Identifies NTLM usage for remediation |
| NTLM denied, Kerberos only with AES | High | Eliminates NTLM attack surface; requires full Kerberos compatibility |
🔁 Transition from NTLM to Kerberos – Real‑World Example
A large enterprise with legacy file servers (Windows Server 2003) decides to migrate to Windows Server 2022. The old servers used NTLM extensively. The migration plan includes:
- Phasing out old servers and replacing with new ones.
- Ensuring all new servers have correct SPNs (automatically registered for domain‑joined machines).
- Configuring Group Policy to first audit, then restrict NTLM.
- Training helpdesk to recognise Kerberos-related errors (e.g., time skew, SPN missing).
- Using tools like
klistandsetspnto troubleshoot. - After six months, setting “Deny all” for NTLM, with exceptions only for a few verified legacy systems isolated in a separate network segment.
The result: reduced attack surface, fewer authentication failures, and compliance with security mandates.
6.3 Least Privilege Model – Comprehensive Implementation Guide
🔐 What is Least Privilege? The Foundation of Zero Trust
The principle of least privilege is a cornerstone of information security. It dictates that any entity (user, application, process, or device) should be granted only the minimum set of permissions, rights, and access necessary to perform its legitimate functions – and no more. This principle is fundamental to reducing attack surface, limiting blast radius, and preventing lateral movement in the event of a compromise.
In the context of Active Directory, least privilege is not merely a recommendation; it is a critical control mandated by numerous compliance frameworks (ISO 27001, NIST 800-53, PCI DSS, CIS Benchmarks). Despite this, many organisations still operate with over‑privileged accounts, granting users administrative rights they do not need, and allowing service accounts to roam freely with excessive privileges.
Imagine a hotel. The housekeeper has a key that opens guest rooms (their job). The manager has a master key that opens all rooms and offices. The accountant only has access to the finance office. Least privilege ensures the housekeeper doesn't have the manager's master key, and the accountant can't access guest rooms. If a thief steals the housekeeper's key, only a few rooms are compromised, not the entire hotel.
🧩 The Principle in Depth: Beyond Users
Least privilege applies to multiple layers:
- User accounts: Standard users should not have local admin rights on their workstations. They should not be members of privileged AD groups.
- Administrative accounts: Admins should use separate accounts for privileged tasks, and those accounts should have narrowly scoped permissions (e.g., only able to manage specific OUs).
- Service accounts: Many service accounts are configured as Domain Admins out of convenience. This is a critical vulnerability. Service accounts should have only the specific permissions required to run their service (e.g., read/write to a particular file share, permission to update a specific attribute).
- Computer accounts: Computers themselves have accounts in AD. They should not have unnecessary privileges (e.g., a file server does not need to be able to create user accounts).
- Applications and processes: Even within an application, the principle applies. A web server process should not run as SYSTEM; it should run with a least‑privileged service account.
👥 Tiered Administrative Model – The Microsoft Enterprise Access Model
Microsoft's Enterprise Access Model (formerly the Tiered Administration Model) is a proven framework for implementing least privilege in Active Directory. It divides the environment into three tiers, with strict controls on what accounts can access which resources.
- Tier 0 (Identity and Control Plane):
- Includes: Domain controllers, Active Directory, Azure AD Connect, AD FS servers, PKI (Certificate Authority) servers, and any system with direct control over the identity store.
- Admins: Only Tier 0 administrators can log on to these systems. These admins have accounts that are members of groups like Domain Admins, Enterprise Admins, Schema Admins, or built‑in Administrators on DCs.
- Security boundary: Compromise of Tier 0 gives the attacker complete control over the entire forest.
- Tier 1 (Server and Application Infrastructure):
- Includes: File servers, application servers, database servers, web servers, and other infrastructure servers that do not control identity.
- Admins: Tier 1 administrators manage these servers. They may have local admin rights on these machines but should not have any Tier 0 access.
- Security boundary: Compromise of Tier 1 gives the attacker access to application data and server control, but not to the identity layer.
- Tier 2 (User Workstations and Devices):
- Includes: End‑user workstations, laptops, tablets, and other user devices.
- Admins: Tier 2 administrators (often helpdesk) can manage these devices – resetting local passwords, installing software, etc. They should not have access to Tier 0 or Tier 1 systems.
- Security boundary: Compromise of a Tier 2 device gives the attacker a foothold on a user's machine, but not on servers or identity systems.
The Golden Rule: Accounts from a higher tier can log on to lower‑tier systems, but accounts from a lower tier cannot log on to higher‑tier systems. For example:
- A Tier 0 admin (using their Tier 0 account) can log on to a file server (Tier 1) to perform maintenance.
- A Tier 1 admin (using their Tier 1 account) must never log on to a domain controller (Tier 0). If they need to perform a Tier 0 task, they must use a separate Tier 0 account (and ideally a separate PAW).
🛡️ Implementing Tier Separation
To enforce tier separation, you need a combination of technical controls:
- Separate administrative accounts: Each administrator should have at least two accounts: one for daily work (Tier 2) and one for their administrative role (Tier 1 or Tier 0). In high‑security environments, admins may have separate accounts for each tier they manage.
- Privileged Access Workstations (PAWs): As described below, PAWs are dedicated workstations for administrative tasks. They are configured to only allow logon by administrative accounts and are hardened against compromise.
- Logon restrictions: Use Group Policy or fine‑grained logon rights to restrict where admin accounts can log on. For example, configure "Deny log on locally" and "Deny log on through Remote Desktop" for Tier 0 accounts on all non‑Tier 0 systems.
- Just Enough Administration (JEA): Limit what admins can do on target systems (see below).
- Just‑In‑Time (JIT) access: Grant temporary membership in privileged groups only when needed (see 6.6).
🖥️ Privileged Access Workstations (PAWs) – Detailed Implementation
A PAW is a hardened workstation used exclusively for administrative tasks. It is the most effective control against credential theft for high‑privileged accounts. PAWs are mandatory for Tier 0 administrators and strongly recommended for Tier 1.
Key characteristics of a PAW:
- Dedicated purpose: Used only for administration – no email, no web browsing, no document editing. This reduces the attack surface dramatically.
- Clean operating system: Fresh installation with only necessary administrative tools (RSAT, custom scripts, etc.).
- Application control: Use AppLocker or Windows Defender Application Control (WDAC) to allow only authorised applications.
- Device guard / Credential Guard: Enabled to protect LSASS from credential theft.
- BitLocker: Full disk encryption to protect data at rest.
- Network isolation: Ideally, the PAW is not on the same network as user workstations. It may have restricted internet access (e.g., through a filtered proxy).
- Regular patching: PAWs must be kept up‑to‑date with security patches, often using a dedicated update infrastructure.
- Separate administrative accounts: Only privileged accounts (Tier 0 or Tier 1) are allowed to log on to the PAW. Standard user accounts are blocked.
PAW Deployment Options:
- Physical PAW: A dedicated physical machine. Most secure but more expensive.
- Virtual PAW: A virtual machine on a secure host (e.g., a dedicated virtualization server). Allows easier management and isolation.
- Cloud‑based PAW: Using Windows 365 or Azure Virtual Desktop to provide a cloud‑hosted administrative workstation. This can be very effective for hybrid environments.
📉 Just Enough Administration (JEA) – Granular Delegation
JEA is a PowerShell‑based technology that allows you to delegate specific administrative tasks without granting full administrative rights. It works by creating a constrained PowerShell session endpoint (a "JEA endpoint") that connects to a target machine. When a user connects to this endpoint, they are mapped to a virtual account (temporary, with just‑in‑time privileges) that has only the permissions necessary to run a predefined set of commands.
Benefits of JEA:
- Principle of least privilege: Users get only the exact permissions they need, not full admin rights.
- Reduced lateral movement: Even if a user's credentials are stolen, the attacker can only run the allowed commands, not take over the machine.
- Full auditing: Every command run through JEA is logged (with detailed transcription), providing an audit trail.
- No permanent elevation: The virtual account exists only for the duration of the session.
Example JEA Scenario:
Helpdesk staff need to reset user passwords and manage group memberships on domain controllers (Tier 0). Instead of making them Domain Admins, you create a JEA endpoint on the DCs that exposes only the Reset-ADAccountPassword and Add-ADGroupMember cmdlets, constrained to specific OUs. The helpdesk connects to the endpoint, performs the task, and the session ends. They never have a full interactive logon on the DC.
Implementing JEA:
- Create a role capability file (.psrc) that defines which cmdlets and functions are available.
- Create a session configuration file (.pssc) that maps users/groups to the role capability and specifies the virtual account.
- Register the JEA endpoint using
Register-PSSessionConfiguration. - Configure WinRM and firewall rules to allow connections.
- Train users to connect using
Enter-PSSession -ComputerName DC01 -ConfigurationName JEA-Endpoint.
🔑 Local Administrator Password Solution (LAPS) – In Depth
LAPS (Local Administrator Password Solution) is a Microsoft tool that automatically manages local administrator passwords on domain‑joined computers. It solves the problem of identical local admin passwords across many machines – a common vector for lateral movement in Pass‑the‑Hash attacks.
How LAPS Works:
- LAPS is installed on each workstation/server (via Group Policy or endpoint management).
- A client‑side extension periodically generates a new, random password for the local administrator account (or any specified local account).
- The password is stored in Active Directory as an attribute (
ms-Mcs-AdmPwd) on the computer object. The password is encrypted during transmission and storage. - Only authorised users (e.g., helpdesk) are granted read access to this attribute. They can retrieve the password when needed (e.g., for remote support).
- The old password is then changed after use.
Key Benefits:
- Unique local admin passwords for every machine – if one machine is compromised, its local admin password cannot be used on others.
- Passwords are strong and rotated regularly (configurable).
- Auditing: Access to passwords is logged in AD.
- Integration with existing AD infrastructure.
Implementation Steps:
- Download and install LAPS on management workstations (for GPO administration).
- Extend the AD schema to add the LAPS attributes (run
Update-LapsADSchema). - Delegate permissions to computer objects so that machines can update their own password attribute.
- Create a GPO to deploy the LAPS client and configure policy (e.g., password complexity, rotation frequency).
- Delegate read access to the password attribute to authorised helpdesk groups.
- Test and deploy.
📋 Comprehensive Least Privilege Implementation Plan
Moving to a least‑privilege model is a journey. Here is a phased, practical plan:
Phase 1: Discovery and Inventory
- Identify all privileged groups in AD: Domain Admins, Enterprise Admins, Schema Admins, Administrators, Backup Operators, Account Operators, Server Operators, Print Operators, etc.
- List all members of these groups. Use tools like
Get-ADGroupMemberorNetwrix Auditor. - Document service accounts and their current privileges (many are over‑privileged).
- Identify where users are local administrators on their own workstations (via local group membership or Group Policy).
- Run tools like BloodHound to visualise attack paths and identify over‑privileged accounts.
- Use PingCastle or Purple Knight to assess the current security posture.
Phase 2: Design and Planning
- Define the tier boundaries (Tier 0, 1, 2) for your organisation.
- Design the new administrative structure:
- Create new groups for each tier and function (e.g., "Tier0-Admins", "Tier1-FileServer-Admins", "Tier2-Helpdesk").
- Plan separate admin accounts for each administrator (e.g., user_jdoe, admin_jdoe_t0, admin_jdoe_t1).
- Design PAW deployment (which admins get PAWs, where they will be located).
- Plan the rollout of LAPS and JEA for specific use cases.
- Develop a communication and training plan for administrators and users.
Phase 3: Implementation and Hardening
- Create dedicated admin accounts: For each administrator, create the required separate accounts. Use a naming convention (e.g., first.last, first.last_adm, first.last_t0).
- Populate new groups: Add the new admin accounts to the appropriate tier groups.
- Deploy PAWs: For Tier 0 admins (and optionally Tier 1), set up PAWs. Harden them using security baselines (e.g., Microsoft Security Compliance Toolkit).
- Implement logon restrictions:
- Use Group Policy to configure "Deny log on locally", "Deny log on through Remote Desktop", etc., for privileged accounts on lower‑tier systems.
- Configure "Allowed logon workstations" (userWorkstations attribute) for Tier 0 accounts to restrict them to PAWs.
- Remove over‑privileged memberships: Carefully remove users from overly privileged groups (e.g., Domain Admins) after verifying they have alternative access.
- Restrict local admin rights on workstations:
- Remove "Domain Users" from the local Administrators group using Group Policy (Restricted Groups).
- Add only specific groups (e.g., "Tier2-Helpdesk") to local Administrators where needed.
- Use LAPS to manage the built‑in local Administrator password.
- Harden service accounts:
- Replace manually managed service accounts with Group Managed Service Accounts (gMSAs) where possible. gMSAs have automatic password rotation and are least‑privilege by design.
- Review permissions for each service account and reduce them to the minimum required.
- Never use Domain Admins as service accounts.
- Implement JEA for key delegation scenarios: Start with one or two critical tasks (e.g., password reset on DCs).
Phase 4: Monitoring and Auditing
- Enable auditing for privileged group changes (Event IDs 4728, 4732, 4756, etc.).
- Monitor logon events for privileged accounts (Event ID 4672 – special privileges assigned). Alert on any logon of a Tier 0 account to a non‑PAW machine.
- Use a SIEM to correlate and alert on anomalous behaviour.
- Regularly review membership of privileged groups (monthly).
- Run periodic security assessments with tools like PingCastle to track progress.
Phase 5: Ongoing Maintenance and Improvement
- Establish a process for requesting and approving temporary privilege elevation (JIT).
- Regularly rotate passwords for critical accounts (including KRBTGT – twice, with a delay).
- Keep up with Microsoft security recommendations and adjust policies accordingly.
- Conduct regular penetration testing focused on AD attack paths.
🔍 Common Pitfalls and How to Avoid Them
- Pitfall: Creating admin accounts but still using the old ones. Solution: Monitor logons and enforce use of new accounts. Eventually disable old accounts.
- Pitfall: PAWs not truly isolated (e.g., users browse the web on them). Solution: Enforce strict application control and web filtering; educate users.
- Pitfall: Service accounts with expired passwords causing outages. Solution: Use gMSAs or managed service accounts (MSAs) with automatic password management.
- Pitfall: "Temporary" membership in privileged groups becoming permanent. Solution: Implement JIT access with approval workflows.
- Pitfall: LAPS not deployed to all machines. Solution: Use GPO to enforce LAPS installation and monitor compliance.
📊 Measuring Success: KPIs for Least Privilege
- Percentage of users with local admin rights on workstations: Target 0% (except for specific, justified exceptions).
- Number of Domain Admin members: Should be a very small, documented set (ideally fewer than 5).
- Coverage of LAPS: 100% of domain‑joined workstations and servers.
- Number of service accounts with Domain Admin privileges: 0.
- Percentage of administrative logons originating from PAWs: For Tier 0, target 100%.
- Reduction in attack paths as identified by BloodHound.
Least privilege is not a one‑time project but a continuous discipline. By implementing the tiered model, PAWs, LAPS, JEA, and rigorous monitoring, you can dramatically reduce the risk of credential theft and lateral movement. Every organisation should prioritise these controls as part of a defence‑in‑depth strategy.
6.4 Protecting Admin Accounts – The Crown Jewels of Active Directory
🎯 Why Admin Accounts Are Prime Targets – Understanding the Threat Landscape
Administrative accounts are the crown jewels of any Active Directory environment. These accounts possess elevated privileges that allow them to reset passwords, modify group memberships, change security policies, configure domain controllers, and ultimately control the entire identity infrastructure. Attackers specifically target these accounts because compromising just one can lead to full domain compromise, often within hours.
The statistics are sobering: according to numerous breach reports, over 90% of organisations have experienced some form of credential theft, and privileged account compromise is a leading cause of major breaches. Attackers use techniques like spear‑phishing, password spraying, pass‑the‑hash, and token theft to capture admin credentials. Once they have a foothold, they move laterally, escalate privileges, and establish persistence.
🔑 Separate Admin Accounts – The Non‑Negotiable Foundation
The single most effective control to protect admin accounts is to ensure that every administrator has at least two separate accounts:
- Standard user account: Used for day‑to‑day activities – email, web browsing, document editing, and non‑administrative access to resources. This account should have no administrative privileges whatsoever. It should be a member of only standard user groups (e.g., Domain Users) and subject to regular security policies (password expiration, MFA if available).
- Administrative account(s): Used exclusively for privileged tasks. These accounts:
- Should have a naming convention that clearly distinguishes them (e.g.,
first.last_adm,first.last_t0for Tier 0,first.last_t1for Tier 1). - Must have strong, unique passwords (ideally 20+ characters, randomly generated).
- Should not be used for email, web browsing, or any interactive logon on untrusted systems.
- Should be members of only the necessary privileged groups (e.g., Domain Admins for Tier 0, specific server admin groups for Tier 1).
- Should be configured with additional security controls (see below).
- Should have a naming convention that clearly distinguishes them (e.g.,
In high‑security environments, administrators may need multiple admin accounts for different tiers. For example, a senior administrator might have:
john.doe– Standard user account.john.doe_t0– Tier 0 admin account (used only on PAWs to manage DCs).john.doe_t1– Tier 1 admin account (used to manage file servers and applications).
This separation ensures that if a lower‑tier admin account is compromised, the attacker cannot directly access higher‑tier systems.
🛡️ Multi‑Factor Authentication (MFA) for Admin Accounts – Raising the Bar
Passwords alone are no longer sufficient to protect privileged accounts. Phishing, password reuse, and credential theft are too common. Multi‑factor authentication (MFA) adds a critical layer of security, requiring something the user knows (password) and something they have (smart card, token, phone) or something they are (biometric).
Options for MFA with Active Directory:
- Smart Cards (Physical or Virtual):
- Physical smart cards (e.g., Common Access Cards, PIV cards) store a certificate and private key. Windows can be configured to require smart card logon for interactive sessions, RDP, and even for administrative tools like PowerShell.
- Virtual smart cards use the Trusted Platform Module (TPM) on the device to emulate a smart card, providing similar security without a physical card.
- Smart cards are FIPS 140‑2 compliant and provide strong, certificate‑based authentication.
- Configuration: Use Group Policy to set "Interactive logon: Require smart card" for admin accounts, and deploy certificate infrastructure (AD CS).
- Windows Hello for Business (WHfB):
- WHfB replaces passwords with strong two‑factor authentication on modern devices. It uses a PIN (something you know) and biometrics (fingerprint, facial recognition) or a TPM (something you have).
- It integrates with on‑premises AD (via hybrid or key trust models) and Azure AD.
- For on‑premises only, you can deploy WHfB with certificate trust, using AD CS.
- Azure AD / Third‑Party MFA for Hybrid Environments:
- If you have hybrid identity (Azure AD Connect), you can use Azure AD Conditional Access to require MFA for privileged roles (e.g., Global Administrator). This does not directly protect on‑premises admin logons but can protect cloud‑connected admin activities.
- Third‑party MFA solutions (e.g., Duo Security, RSA SecurID) can integrate with Windows logon via RADIUS or custom agents, providing MFA for RDP and interactive logons.
Implementation Best Practices:
- Start with Tier 0 admin accounts – require smart card or WHfB for all interactive logons.
- For Tier 1 and Tier 2 admin accounts, consider MFA for RDP access (e.g., via RD Gateway with MFA).
- Ensure you have a break‑glass procedure for emergency access when MFA is unavailable (e.g., a highly secured, offline emergency account).
🔒 Restricting Admin Logon Hours and Workstations – Reducing Attack Surface
Even with separate accounts and MFA, you can further limit exposure by restricting where and when admin accounts can log on.
Logon Workstation Restrictions:
- In Active Directory, each user account has a
userWorkstationsattribute (visible in ADUC under the "Account" tab → "Log On To…"). This allows you to specify a list of computer names (NetBIOS names) from which the user is allowed to log on. - For Tier 0 admin accounts, this should be restricted to only their assigned Privileged Access Workstations (PAWs). For example, you might allow logon only from
PAW-JDOE-01andPAW-JDOE-02. - This control is effective against attackers who have stolen credentials but are trying to use them from an unauthorised machine. However, it is not foolproof – an attacker who compromises the PAW itself can still use the account.
- Implementation: Use a script or tool to set the
userWorkstationsattribute. Note that this attribute has a character limit and can only specify up to 8 workstations (in the legacy UI). For more flexibility, use theuserWorkstationsattribute with comma‑separated values via PowerShell.
Logon Hour Restrictions:
- AD allows you to restrict the hours during which a user can log on to the domain. This is configured in ADUC under the "Account" tab → "Logon Hours".
- For admin accounts, you can restrict logon to business hours (e.g., 8 AM – 6 PM, Monday to Friday). This limits the window in which an attacker can use stolen credentials, especially if the attack occurs outside normal hours.
- However, be cautious: some administrative tasks (e.g., patching, disaster recovery) may need to occur outside these hours. You may need to create a separate process for after‑hours access (e.g., a JIT elevation workflow).
PowerShell Example to Set Logon Workstations:
# Set logon workstations for a Tier 0 admin account
Set-ADUser jdoe_t0 -LogonWorkstations "PAW-JDOE-01,PAW-JDOE-02"
🔐 Protected Users Group – The Built‑In Security Booster
Introduced in Windows Server 2012 R2, the Protected Users global group is one of the most powerful yet underutilised security controls in Active Directory. When you add a user to this group, they automatically receive non‑configurable, hard‑coded protections that significantly reduce their attack surface.
Protections Applied to Protected Users:
- No NTLM authentication: Members cannot authenticate using NTLM, NTLMv2, or any other NTLM variant. This completely blocks pass‑the‑hash and NTLM relay attacks for these accounts.
- No Kerberos delegation: Unconstrained or constrained delegation cannot be used with Protected Users accounts. This prevents attackers from using delegation to impersonate the user.
- No DES or RC4 encryption in Kerberos: The KDC will only issue tickets using AES encryption. This mitigates attacks that target weak encryption (e.g., Kerberoasting with RC4).
- No credential delegation (CredSSP): Protections against credential forwarding via CredSSP (used in some Remote Desktop scenarios).
- Reduced Kerberos ticket lifetime: The TGT lifetime is set to 4 hours (down from the default 10). This limits the window of opportunity for ticket theft.
- No offline credential caching: The user's credentials are not cached on the local machine, reducing the risk of credential theft from memory.
Implementation Guidance:
- Add all Tier 0 admin accounts (Domain Admins, Enterprise Admins, etc.) to the Protected Users group.
- Consider adding Tier 1 and Tier 2 admin accounts as well, after verifying that no legacy applications rely on NTLM or weak Kerberos encryption for these accounts.
- Be aware that Protected Users cannot authenticate to down‑level servers (pre‑Windows Server 2008) that do not support AES Kerberos. Ensure all servers that admins need to access are at a supported level.
- Test thoroughly in a pilot group before rolling out widely.
PowerShell to Add Users to Protected Users Group:
Add-ADGroupMember -Identity "Protected Users" -Members "jdoe_t0", "asmith_t0"
📜 Just‑In‑Time (JIT) Administration – Eliminating Standing Privileges
The concept of JIT administration is simple: no user should have permanent privileged access. Instead, they request elevation for a specific task, receive temporary membership in a privileged group, and lose that access after the task is complete (or after a short, predefined period). This drastically reduces the attack surface because there are no standing privileged accounts that an attacker can target.
JIT Implementation Options:
- Microsoft Identity Manager (MIM) Privileged Access Management (PAM):
- MIM PAM uses a bastion forest – a separate, hardened Active Directory forest that is highly trusted but isolated. Users request elevation, and their membership in privileged groups is granted for a limited time using time‑based group membership (via the
msDS-NeverRevealGroupandmsDS-RevealOnDemandGroupattributes). - MIM PAM provides extensive auditing, approval workflows, and integration with existing AD.
- It is complex to set up but provides the highest level of security for on‑premises environments.
- MIM PAM uses a bastion forest – a separate, hardened Active Directory forest that is highly trusted but isolated. Users request elevation, and their membership in privileged groups is granted for a limited time using time‑based group membership (via the
- Azure AD Privileged Identity Management (PIM):
- For hybrid or cloud‑only environments, Azure AD PIM provides JIT access to Azure AD roles (e.g., Global Administrator) and Azure resources. It can also manage just‑in‑time access for on‑premises roles if you use Azure AD Connect and configure PIM for Groups.
- PIM includes approval workflows, activation notifications, and detailed audit logs.
- Third‑Party PAM Solutions:
- Tools like CyberArk Privileged Access Security, BeyondTrust PowerBroker, and Thycotic Secret Server provide comprehensive privileged account management, including JIT elevation, session isolation, and credential vaulting.
- These solutions often integrate with AD to manage group memberships dynamically.
- Manual or Scripted JIT:
- For smaller environments, you can implement a simple JIT process using scheduled scripts and temporary group membership. For example, a helpdesk ticket could trigger a script that adds a user to a group for 4 hours, then removes them.
- This is less secure than a full PAM solution but better than permanent standing privileges.
Example JIT Workflow (with MIM PAM):
- Admin requests elevation to Domain Admin via a web portal, specifying a reason and duration.
- Manager approves the request (or it is auto‑approved based on policy).
- MIM adds the admin's account to the "Domain Admins" group in the bastion forest for the specified duration.
- The admin performs necessary tasks using a PAW that trusts the bastion forest.
- After the time expires, the membership is automatically removed. All actions are logged.
🕵️ Monitoring Admin Activity – Visibility is Security
Even with all the preventive controls in place, you must assume that some attacks will succeed. Comprehensive monitoring and alerting on administrative activity is essential for early detection and response.
Critical Event IDs to Monitor:
| Event ID | Description | Why Monitor |
|---|---|---|
| 4720 | A user account was created. | Unauthorised account creation could indicate a backdoor. |
| 4728 / 4732 / 4756 | Member added to security‑enabled global/local/universal group. | Especially monitor additions to privileged groups (Domain Admins, etc.). |
| 4735 / 4737 | Security‑enabled group changed. | Changes to privileged group settings. |
| 4672 | Special privileges assigned to new logon. | Indicates a user logged on with admin rights (e.g., as Administrator or with SeTcbPrivilege). Correlate with logon event 4624. |
| 4624 / 4625 | Logon / logoff events. | Track all admin logons. Look for logons from unusual workstations or at unusual times. |
| 4648 | A logon was attempted using explicit credentials. | Detects when a user runs a process as another user (e.g., runas). |
| 4662 | An operation was performed on an object. | Monitor for changes to sensitive AD objects (e.g., AdminSDHolder, Domain Controllers OU). |
| 5136 / 5137 / 5141 | Directory service object modified/created/deleted. | Detailed audit of AD changes; essential for tracking modifications. |
| 4776 / 4771 | NTLM / Kerberos authentication failures. | Failed admin logons could indicate password guessing. |
Building an Effective Monitoring Strategy:
- Enable Advanced Audit Policies: Use Group Policy to enable detailed auditing on domain controllers and critical servers. At minimum, enable:
- Audit Account Management (Success, Failure)
- Audit Logon Events (Success, Failure)
- Audit Privilege Use (Success, Failure)
- Audit Directory Service Access (Success, Failure)
- Centralise Log Collection: Forward all critical events to a SIEM (e.g., Azure Sentinel, Splunk, QRadar). This enables correlation, alerting, and long‑term retention.
- Create Alerts for Anomalies:
- Alert on any addition of a user to a privileged group (especially if done outside approved hours).
- Alert on logon of a Tier 0 account from a non‑PAW machine.
- Alert on multiple failed logons for admin accounts (potential brute force).
- Alert on changes to the AdminSDHolder container.
- Alert on DCSync attempts (Event ID 4662 with control access right "DS-Replication-Get-Changes").
- Regularly Review Admin Activity: Even with alerts, conduct periodic manual reviews of admin actions. Use tools like
Get-ADEventor SIEM reports to generate weekly summaries.
🛡️ Additional Hardening Measures for Admin Accounts
- Disable inactive admin accounts: Regularly review and disable or delete admin accounts that are no longer needed (e.g., former employees).
- Rename or disable built‑in Administrator account: The built‑in Administrator account (SID S-1-5-21-...-500) is a well‑known target. Rename it via Group Policy and consider disabling it (but ensure you have another account with equivalent privileges).
- Set "Account is sensitive and cannot be delegated": For Tier 0 accounts, enable this flag (in ADUC) to prevent them from being delegated to services. This is automatically enforced by Protected Users, but can be set manually for other accounts.
- Use fine‑grained password policies: Apply stricter password policies (e.g., 20+ characters, no expiry) to admin accounts via FGPP.
- Implement Credential Guard: On all PAWs and admin workstations, enable Windows Defender Credential Guard to protect LSASS from credential theft.
- Restrict RDP access: Use Remote Desktop Gateway (RD Gateway) with MFA for any remote admin access. Block direct RDP to domain controllers and other sensitive servers.
- Secure the PAW: Ensure PAWs are themselves hardened with application whitelisting, limited internet access, and regular patching.
📋 Comprehensive Admin Account Protection Checklist
| Control | Status | Notes |
|---|---|---|
| Separate admin accounts for each administrator | At least one standard + one admin | |
| Admin accounts have strong, unique passwords | 20+ characters, random | |
| Admin accounts added to Protected Users group | For all Tier 0 and ideally Tier 1 | |
| MFA required for all admin logons | Smart card, WHfB, or MFA via RD Gateway | |
| Logon workstations restricted for Tier 0 accounts | Only PAWs allowed | |
| Logon hours restricted (if feasible) | Consider business hours only | |
| JIT administration implemented for privileged roles | MIM PAM, Azure PIM, or third‑party | |
| Auditing enabled for all admin actions | Advanced Audit Policy configured | |
| SIEM alerts configured for critical events | Group changes, unusual logons | |
| Built‑in Administrator account renamed/disabled | Via GPO or manually | |
| Credential Guard enabled on PAWs | Windows Defender Credential Guard | |
| LAPS deployed for local admin passwords | Even for admin workstations | |
| Regular review of privileged group membership | Monthly audits |
🔁 Break‑Glass (Emergency) Accounts
No matter how well you protect your admin accounts, there may be emergencies where normal access is unavailable (e.g., network outage, MFA system failure, or compromise of all regular admin accounts). For these scenarios, you must have break‑glass accounts – highly secured, emergency access accounts.
Characteristics of Break‑Glass Accounts:
- Extremely long, complex passwords (30+ characters, randomly generated), stored in a secure, offline location (e.g., a physical safe with dual‑control access).
- Not subject to normal password expiration (to avoid the risk of expiry during an emergency).
- Excluded from MFA requirements (since MFA might be unavailable).
- Strictly limited in number (e.g., two accounts per forest).
- Logon restricted to specific, highly secure workstations (maybe even physically isolated).
- Audited every time they are used; any use triggers an immediate security alert.
- Passwords are changed immediately after any use.
Store the passwords in a sealed envelope or a password manager with strict access controls. Document the procedure for using break‑glass accounts and test it periodically.
Protecting admin accounts is not about implementing a single control – it's about building a layered defence. Separate accounts, MFA, Protected Users, JIT access, and continuous monitoring work together to make it extremely difficult for an attacker to successfully compromise and use a privileged account. Invest the time and resources to get this right; it's the most effective way to prevent a catastrophic AD breach.
6.5 AD Attack Techniques – Understanding the Adversary's Playbook
🎭 Understanding the Adversary – The Mindset of an Attacker
To effectively harden Active Directory, you must think like an attacker. Adversaries are not random; they follow a methodical process, often leveraging the very features and protocols designed to make AD functional against itself. Understanding these techniques is crucial because it allows you to implement targeted defences and recognise early warning signs of compromise.
The attacks covered in this section – Pass‑the‑Hash, Golden Ticket, Silver Ticket, DCSync, Kerberoasting, and AS‑REP Roasting – represent some of the most common and devastating techniques used in real‑world breaches. They abuse fundamental components of AD: NTLM authentication, Kerberos ticketing, and replication protocols. By understanding how each attack works at a technical level, you can better appreciate the mitigations and monitoring strategies that follow.
🔑 Pass‑the‑Hash (PtH) – The Classic Lateral Movement Technique
What it is: Pass‑the‑Hash is an attack that allows an attacker to authenticate to remote systems using the NTLM hash of a user's password, without ever needing the plaintext password. This works because NTLM authentication protocols use the hash as the secret – if you have the hash, you can impersonate the user.
Technical Deep Dive – How PtH Works:
- Initial Compromise: The attacker gains a foothold on a workstation or server through phishing, unpatched software, or other means. They may have limited privileges initially.
- Credential Extraction: Using tools like Mimikatz, Windows Credential Editor, or even custom scripts, the attacker extracts NTLM hashes from the LSASS (Local Security Authority Subsystem Service) process memory. LSASS caches credentials of logged‑on users to enable single sign‑on. If a Domain Admin has recently logged on to that machine (even remotely via RDP), their hash may be present.
- Hash Reuse: The attacker now has the NTLM hash of a privileged user. They use tools like Mimikatz's
sekurlsa::pthorInvoke-TheHashPowerShell scripts to create a new logon session using the hash. This new session can authenticate to other machines on the network that accept NTLM authentication. - Lateral Movement: The attacker uses the hash to connect to file servers, database servers, or other workstations. They may use tools like PsExec, WMI, or Scheduled Tasks to execute code remotely. Each new compromised machine becomes a hunting ground for more credentials.
- Goal: Domain Controller Access: The attacker repeats the process, moving laterally until they reach a domain controller. Once on a DC, they can extract the KRBTGT hash (leading to Golden Ticket) or create new admin accounts.
Why PtH is so Effective:
- No need to crack the hash – the hash itself is the authentication credential.
- Works across the network; attacker does not need to be on the same machine.
- Many organisations still have widespread NTLM usage, especially in mixed environments.
- Local admin hash reuse (identical local admin passwords across many machines) makes PtH trivial.
Advanced PtH Variants:
- Overpass‑the‑Hash (Pass‑the‑Key): Instead of using NTLM, the attacker converts the hash into a Kerberos ticket, allowing Kerberos authentication. This can bypass some NTLM restrictions.
- Pass‑the‑Ticket: Using stolen Kerberos tickets instead of hashes.
Comprehensive Mitigations:
- Enable Windows Defender Credential Guard: Credential Guard uses virtualization‑based security to protect LSASS secrets. Even if an attacker has admin rights, they cannot extract hashes from a protected LSASS. Requires Windows 10 Enterprise/Education or Windows Server 2016+.
- Restrict and Phase Out NTLM: Follow the NTLM hardening steps in section 6.2. If NTLM is not used, PtH becomes ineffective (though Overpass‑the‑Hash may still work if RC4 is enabled).
- Use Protected Users Group: As covered in 6.4, members of Protected Users cannot use NTLM authentication, directly blocking PtH.
- Implement Least Privilege: Ensure that only necessary users have local admin rights on workstations. If an attacker compromises a standard user, they cannot extract hashes of other users (since they can't run Mimikatz with admin rights).
- LAPS for Local Admin Passwords: Use LAPS to give every machine a unique local admin password. This prevents lateral movement using shared local admin hashes.
- Disable WDigest: WDigest protocol (disabled by default in modern Windows) caches plaintext passwords. Ensure it's disabled via Group Policy.
- Network Segmentation: Isolate critical systems (Tier 0) on separate network segments with strict firewall rules. An attacker on a workstation should not be able to reach a domain controller directly.
- Monitor for PtH Activity: Look for Event ID 4624 (logon) with Logon Type 3 (network) and Logon Process "NtLmSsp". Correlate with unusual source IPs. Also monitor for Event ID 4672 (special privileges assigned) for accounts that shouldn't have them.
👑 Golden Ticket Attack – The Ultimate Persistence
What it is: A Golden Ticket attack allows an attacker to forge a TGT (Ticket Granting Ticket) for any user, including non‑existent ones, with any group memberships (like Domain Admins). The forged ticket is signed with the KRBTGT account's password hash, making it indistinguishable from a real ticket.
Technical Deep Dive – How Golden Ticket Works:
- KRBTGT Hash Extraction: The attacker must first obtain the KRBTGT hash. This requires domain admin or equivalent privileges, typically achieved by compromising a domain controller or extracting the hash from a DC's LSASS (if Credential Guard is not enabled) or from the NTDS.dit database (if backups are compromised).
- Ticket Forgery: Using Mimikatz (or similar tools), the attacker runs
kerberos::goldenwith parameters:/user:– Any username, often a fake or existing admin (e.g., "Administrator")./domain:– The domain FQDN./sid:– The domain SID./krbtgt:– The KRBTGT hash./id:– The desired user RID (500 for built‑in admin)./groups:– Group RIDs (e.g., 512 for Domain Admins)./startoffset /endoffset /renewoffset:– To set ticket validity (can be years)./ptt:– Injects the ticket into current session.
- Ticket Injection: The forged TGT is injected into the attacker's current logon session. The Windows Kerberos package now treats the attacker as the forged user.
- Unlimited Access: With the forged TGT, the attacker can request Service Tickets for any resource in the domain. They can access file servers, databases, domain controllers, etc., all while appearing as a legitimate user.
Why Golden Ticket is so Dangerous:
- Indistinguishable: The forged ticket is signed with the real KRBTGT key, so it looks exactly like a real ticket. Logs show normal Kerberos activity.
- Persistence: The ticket can be forged with a lifetime of years. Even if the attacker's original entry point is discovered and cleaned, the Golden Ticket remains valid until the KRBTGT password is changed twice.
- No Need for Password Changes: If the target user changes their password, the Golden Ticket remains valid because it was forged independently of the user's key.
- Privilege Escalation: The attacker can grant themselves any group membership, including Enterprise Admins, Schema Admins, etc.
Comprehensive Mitigations:
- Protect Domain Controllers at All Costs: DCs are Tier 0 assets. Implement PAWs, strict access controls, and monitoring to prevent compromise. If an attacker cannot get the KRBTGT hash, they cannot forge Golden Tickets.
- Regularly Rotate the KRBTGT Password:
- The KRBTGT account has two passwords (old and new) to allow for replication. To invalidate existing Golden Tickets, you must change the password twice, with a delay between changes (to allow replication).
- Microsoft recommends changing the KRBTGT password every 180 days (or after any suspected compromise).
- Use a script to automate this process, ensuring you don't break existing Kerberos operations.
- Important: Changing the KRBTGT password will invalidate all TGTs, causing a temporary authentication storm. Plan carefully.
- Enable Kerberos Armoring (FAST): Kerberos armoring (Flexible Authentication Secure Tunneling) protects the TGS exchange by requiring that TGS requests be signed with the TGT session key. This makes it harder to use forged tickets in some scenarios. Enable via Group Policy: "Computer Configuration → Administrative Templates → System → Kerberos → Support for Kerberos armoring."
- Monitor for Anomalous Ticket Usage:
- Look for Event ID 4768 (TGT requested) with unusual ticket lifetimes (e.g., >10 hours).
- Monitor for Event ID 4769 (Service Ticket requested) where the account name is highly privileged and the source is unusual.
- Use a SIEM to baseline normal Kerberos activity and alert on deviations.
- Enable advanced auditing for Kerberos ticket events.
- Implement Just‑In‑Time Administration: With JIT, there are no standing privileged accounts. Even if an attacker forges a Golden Ticket for a user, that user may not have permanent privileged access. However, JIT does not prevent the attacker from forging tickets for built‑in privileged groups.
- Use Managed Service Accounts (MSAs) and Group MSAs: For service accounts, use gMSAs which have automatic password rotation and are managed by AD, reducing the risk of service account compromise leading to Silver Tickets.
🔗 Silver Ticket Attack – The Stealthier Cousin
What it is: A Silver Ticket is a forged Service Ticket (ST) for a specific service. Unlike a Golden Ticket (which forges a TGT), a Silver Ticket forges an ST, allowing access to a particular service (e.g., a file server, SQL server, or even a domain controller's CIFS service) without ever contacting the KDC.
Technical Deep Dive – How Silver Ticket Works:
- Service Account Hash Extraction: The attacker needs the NTLM hash of the service account (e.g., the computer account of a file server, or a dedicated service account). This can be obtained by compromising the server itself, extracting from LSASS, or from the NTDS.dit if the account is a domain user.
- Ticket Forgery: Using Mimikatz's
kerberos::goldenwith the/serviceparameter (or dedicated tools), the attacker forges an ST for that specific service. They specify the target user, domain SID, service account hash, and service SPN (e.g.,cifs/fileserver.contoso.com). - Service Access: The attacker presents the forged ST directly to the target service. The service decrypts the ticket using its own hash and grants access, never contacting the KDC.
Why Silver Tickets are Dangerous:
- No KDC Contact: Because the attacker never contacts the KDC, there are no corresponding Event IDs 4768 or 4769 on domain controllers. The only logs are on the target service itself (if it logs authentication).
- Persistence: As long as the service account password doesn't change, the Silver Ticket remains valid. Service account passwords (especially computer accounts) change every 30 days by default, but if the attacker has the hash, they can forge tickets until the password changes.
- Targeted Access: An attacker can forge a ticket for a specific high‑value service, like the CIFS service on a domain controller, to access the SYSVOL share and potentially extract more hashes.
Mitigations:
- Protect Service Account Hashes: Apply the same protections as for user accounts. Use Credential Guard on servers to protect LSASS.
- Use Group Managed Service Accounts (gMSAs): gMSAs have automatic, complex password rotation managed by AD. The password changes frequently, limiting the window for Silver Ticket abuse.
- Monitor Service Ticket Usage: On critical servers, enable auditing for logon events. Look for unusual access patterns or access from unexpected source IPs.
- Implement Least Privilege for Service Accounts: Ensure service accounts have only the permissions they need. A service account used for a web server should not be able to access domain controllers.
- Regularly Change Service Account Passwords: For accounts that cannot use gMSAs, implement a regular password rotation policy.
🔄 DCSync Attack – Replicating Your Way to Domain Dominance
What it is: DCSync is a technique that abuses the Directory Replication Service (DRS) Remote protocol (MS‑DRS). An attacker with appropriate privileges (by default, Domain Admins, Enterprise Admins, and Domain Controllers) can impersonate a domain controller and request replication of sensitive data, including password hashes for all users.
Technical Deep Dive – How DCSync Works:
- Privilege Acquisition: The attacker must first gain credentials that have the necessary replication rights. This is often achieved via a Golden Ticket or by compromising a Domain Admin account.
- Mimikatz DCSync: Using Mimikatz's
lsadump::dcsynccommand (or tools like Impacket's secretsdump.py), the attacker specifies a target domain controller and a user account (or all users). - Replication Request: The tool sends a DRSGetNCChanges request to the target DC, asking for replication updates for the specified objects. The DC, believing the request comes from an authorised replicating partner, sends back the requested data, which includes password hashes (NTLM, LM if enabled, and Kerberos keys).
- Harvesting: The attacker now has the password hashes for all users, including the KRBTGT account. They can use these for further attacks (Pass‑the‑Hash, Golden Ticket) or crack them offline.
Why DCSync is Dangerous:
- No Need to Compromise Every DC: The attacker only needs to contact one DC and have the right privileges. They don't need to be on the DC itself.
- Complete Credential Harvest: In one fell swoop, the attacker can obtain the hashes for every account in the domain.
- Difficult to Detect: Replication is a normal DC function. DCSync requests look like legitimate replication traffic, though they originate from a non‑DC source.
Comprehensive Mitigations:
- Restrict Replication Permissions: By default, only Domain Controllers, Enterprise Admins, and Domain Admins have the right to replicate. Audit these groups regularly and ensure no unnecessary accounts are members. Consider creating a dedicated security group for replication and removing these rights from built‑in groups (advanced, requires careful testing).
- Enable Advanced Auditing for Replication:
- Monitor Event ID 4662 – "An operation was performed on an object."
- Look for events where the object type is
%{19195a5b-6da0-11d0-afd3-00c04fd930c9}(the schemaIDGUID for the Domain‑DNS object) and the access mask includesControl Access(right 100) for the control access rightDS-Replication-Get-Changes(GUID:1131f6aa-9c07-11d1-f79f-00c04fc2dcd2). - Alert on any 4662 event with these attributes originating from an IP that is not a known domain controller.
- Use Protected Users and Tiering: Ensure that accounts with replication rights are in Tier 0 and protected with MFA, PAWs, and JIT.
- Monitor for DCSync Tools: Use network monitoring to detect tools like Mimikatz or Impacket communicating on RPC ports used for replication (TCP 135, 445, and dynamically assigned RPC ports). This is challenging but possible with advanced threat protection solutions.
- Deploy Advanced Threat Protection: Tools like Microsoft Defender for Identity specifically detect DCSync activity by analysing replication requests and alerting when a non‑DC makes a replication request.
📊 Kerberoasting – Attacking Service Accounts
What it is: Kerberoasting is an attack that targets service accounts. Any domain user can request a Service Ticket (ST) for any service account that has a Service Principal Name (SPN) registered. The ST is encrypted with the service account's NTLM hash. The attacker extracts the encrypted portion of the ticket and offline‑cracks it to recover the service account's password.
Technical Deep Dive – How Kerberoasting Works:
- SPN Discovery: The attacker enumerates all accounts with SPNs using tools like
Get-ADUser -Filter {ServicePrincipalName -ne "$null"}or built‑in tools likesetspn -Q */*. - Ticket Request: The attacker requests a Service Ticket for a target service account (e.g., for the SPN
MSSQLSvc/sqlserver.contoso.com) using any valid domain user account (even a low‑privileged one). - Ticket Extraction: The attacker receives an ST encrypted with the service account's NTLM hash. They extract the encrypted portion (the "ciphertext") using tools like Mimikatz (
kerberos::list) or Rubeus (Rubeus.exe kerberoast). - Offline Cracking: The attacker takes the extracted hash and cracks it offline using tools like Hashcat or John the Ripper. If the service account has a weak password, it will be cracked, revealing the plaintext password.
Why Kerberoasting is Dangerous:
- Low Privilege Required: Any authenticated domain user can request service tickets.
- Offline Attack: Cracking happens offline, so there's no network noise or account lockouts.
- Service Accounts Often Have Weak Passwords: Many service accounts are manually managed with passwords that rarely change and are often set to "PasswordNeverExpires".
- Potential for Privilege Escalation: If a service account is over‑privileged (e.g., Domain Admin), cracking it gives the attacker high privileges.
Comprehensive Mitigations:
- Use Group Managed Service Accounts (gMSAs): gMSAs have complex, 120‑character random passwords that change automatically every 30 days. They are nearly impossible to crack and render Kerberoasting ineffective because the password is not known to any user.
- Use Managed Service Accounts (MSAs): For older systems, use MSAs (for single servers). They also have automatic password management.
- Strong Passwords for Service Accounts: If you must use standard user accounts as service accounts, ensure they have extremely strong, randomly generated passwords (20+ characters) and change them frequently. Use a password manager.
- Enable AES Encryption: Kerberoasting often targets RC4‑encrypted tickets because they are easier to crack. Disable RC4 and require AES for Kerberos (via Group Policy). This forces attackers to crack AES hashes, which are more difficult.
- Monitor for Unusual Service Ticket Requests:
- Look for Event ID 4769 – A Kerberos service ticket was requested. Filter for accounts that are not typical service accounts, or for multiple requests from the same user for many different services.
- Alert on 4769 events where the ticket encryption type is 0x17 (RC4) if you have disabled RC4.
- Use tools like AADInternals or commercial SIEM rules to detect Kerberoasting.
- Limit SPN Registration: Only allow authorised users to register SPNs. By default, all users can register SPNs on their own accounts, but limit who can register on others.
🌙 AS‑REP Roasting – Attacking Users Without Pre‑Authentication
What it is: AS‑REP Roasting targets user accounts that have the Kerberos pre‑authentication requirement disabled. When pre‑auth is disabled, the KDC will send an AS‑REP (containing encrypted data) without first verifying the user's timestamp. An attacker can request this AS‑REP for any such user and then offline crack the encrypted portion to recover the user's password.
Technical Deep Dive – How AS‑REP Roasting Works:
- Find Vulnerable Accounts: The attacker enumerates users with the
DONT_REQ_PREAUTHflag set (userAccountControl attribute). Tools like Rubeus (Rubeus.exe asreproast) can do this. - Request AS‑REP: The attacker sends an AS‑REQ for one of these users without pre‑authentication data. The KDC responds with an AS‑REP that includes encrypted data (the session key encrypted with the user's password hash).
- Extract and Crack: The attacker extracts the encrypted part and cracks it offline to recover the password.
Mitigations:
- Ensure All User Accounts Require Pre‑Authentication: This is the default in modern AD. Periodically audit for accounts that have pre‑auth disabled. Use PowerShell:
Get-ADUser -Filter {userAccountControl -band 4194304}(4194304 is the DONT_REQ_PREAUTH flag). - Use Strong Passwords: Even with pre‑auth disabled, a strong password makes cracking infeasible.
- Monitor for AS‑REP Requests: Look for Event ID 4768 (TGT requested) where pre‑authentication was not required (failure code 0x6).
🛡️ Comprehensive Attack Detection and Response Table
| Attack | Key Detection Events | What to Look For |
|---|---|---|
| Pass‑the‑Hash | 4624 (Logon Type 3, NtLmSsp), 4672 | Network logons from unusual source IPs; logons with admin privileges for standard users. |
| Golden Ticket | 4768, 4769 | TGT with abnormally long lifetime (>10 hours); TGT requests for non‑existent users; service ticket requests from unusual sources. |
| Silver Ticket | 4624 (on target service) | Logons on critical servers from unexpected source IPs; access patterns out of normal hours. |
| DCSync | 4662 (control access) | 4662 events with GUID for DS-Replication-Get-Changes from non‑DC IPs. |
| Kerberoasting | 4769 (RC4 encryption) | Multiple 4769 events from same user for different SPNs; RC4 encryption type if AES is enforced. |
| AS‑REP Roasting | 4768 (no pre‑auth) | 4768 with failure code 0x6 (pre‑auth required but not provided). |
🔁 Attack Chain Example: From Foothold to Domain Dominance
To illustrate how these attacks are combined, here's a realistic attack chain:
- Initial Access: Attacker phishes a user and gains access to a workstation (Tier 2).
- Credential Harvesting: Using Mimikatz, they extract hashes from LSASS. They find a local admin hash (thanks to LAPS not being deployed).
- Lateral Movement (PtH): They use the local admin hash to move to a file server (Tier 1).
- Privilege Escalation: On the file server, they find a service account with SPN and weak password. They perform Kerberoasting and crack the password, revealing it's a Domain Admin account.
- Domain Admin Access: They use the cracked Domain Admin credentials to log on to a domain controller (Tier 0).
- Persistence (Golden Ticket): On the DC, they extract the KRBTGT hash and forge a Golden Ticket, ensuring persistent access even if the compromised accounts are cleaned.
- Credential Harvesting (DCSync): Using DCSync, they extract all user hashes from AD, including the KRBTGT hash again, and crack high‑value target passwords.
- Goal Achieved: The attacker now has full, persistent control over the entire domain.
Each step in this chain could have been prevented or detected with the controls discussed in this module.
6.6 Hardening & Monitoring Best Practices – The Complete Implementation Guide
🛡️ Introduction: Defence in Depth for Active Directory
Hardening Active Directory is not a single task or a one‑time project. It is an ongoing process of implementing security controls, continuously monitoring for threats, and adapting to new attack techniques. This section consolidates and expands upon all the hardening recommendations from previous sections into a comprehensive, actionable framework. We will cover not only what to implement, but how to implement it, why it matters, and how to verify its effectiveness.
The approach is based on the defence in depth principle: multiple layers of security controls ensure that if one layer fails, others still provide protection. We'll organise the recommendations into logical domains, providing detailed implementation steps, PowerShell commands, Group Policy settings, and monitoring guidance.
📋 Comprehensive Hardening Checklist – Expanded
Below is the expanded checklist with detailed implementation guidance for each item. Use the status column to track progress in your environment.
1. Domain Controllers (Tier 0) – The Crown Jewels
Domain controllers are the most critical assets in Active Directory. Compromise of a DC leads to full domain compromise. Therefore, they must be protected with the highest level of security.
- Physical Security: DCs should be in locked, access‑controlled server rooms or racks with video surveillance. For virtual DCs, ensure the hypervisor host is equally secured and that only authorised administrators have access.
- Operating System Hardening:
- Install only the minimum required roles and features. DCs should not run file services, web servers, or any other workload.
- Apply the latest security patches promptly. Use a patch management solution (e.g., WSUS, SCCM) with a dedicated maintenance window for DCs.
- Enable Credential Guard on DCs (Windows Server 2016+) to protect LSASS. Use Group Policy:
Computer Configuration → Administrative Templates → System → Device Guard → Turn on Virtualization Based Security. Set to "Enabled with UEFI lock" and select "Enabled with Credential Guard". - Enable Windows Defender Antivirus with real‑time protection and cloud‑delivered protection. Exclude AD database files (
ntds.dit, logs) as per Microsoft recommendations to avoid performance issues. - Configure BitLocker on all drives (OS and data) to protect against physical theft. Use Group Policy to manage recovery keys and store them securely in AD.
- Network Security:
- Place DCs on a dedicated management network segment (Tier 0 network) with strict firewall rules. Only allow necessary protocols (e.g., RPC, LDAP, Kerberos, SMB) from authorised sources (e.g., other DCs, PAWs).
- Block all outbound internet access from DCs. They should not need to browse the web or access external resources.
- Enable LDAP signing and LDAP channel binding to prevent LDAP relay attacks. Configure via Group Policy:
Network security: LDAP client signing requirements→ Set to "Require signing".Domain controller: LDAP server signing requirements→ Set to "Require signing".Domain controller: LDAP server channel binding token requirements→ Set to "Always".
- Disable NTLMv1 and enforce NTLMv2 with 128‑bit encryption (see section 6.2 for detailed steps).
- Enable SMB signing on DCs:
Microsoft network server: Digitally sign communications (always)andMicrosoft network client: Digitally sign communications (always).
- Auditing and Logging:
- Enable advanced auditing on DCs for critical categories: Account Logon, Account Management, DS Access, Logon/Logoff, and Privilege Use.
- Forward all security logs to a central SIEM for analysis and long‑term retention.
- Monitor specifically for events indicating DCSync attempts (4662 with replication GUID), unusual Kerberos activity (4768/4769), and changes to privileged groups.
2. Administrative Accounts – Separate, Protect, Monitor
Administrative accounts are the primary target for attackers. Implement the following controls for all admin accounts, with stricter measures for Tier 0.
- Separate Accounts (Standard vs Admin):
- Create a policy requiring every administrator to have at least two accounts. Enforce via regular audits and technical controls (e.g., disabling admin rights on standard accounts).
- Use a clear naming convention: e.g.,
first.lastfor standard,first.last_admfor admin,first.last_t0for Tier 0. - Implement a process for requesting and approving new admin accounts, tied to HR onboarding.
- Protected Users Group:
- Add all Tier 0 admin accounts to the Protected Users group. This enforces AES Kerberos, blocks NTLM, and disables delegation.
- Consider adding Tier 1 and Tier 2 admins after testing. Be aware that Protected Users cannot authenticate to down‑level servers (pre‑2008 R2).
- PowerShell:
Add-ADGroupMember -Identity "Protected Users" -Members "jdoe_t0", "asmith_t0".
- Multi‑Factor Authentication (MFA):
- Require smart card authentication for all interactive logons of Tier 0 accounts. Deploy a Public Key Infrastructure (PKI) with Active Directory Certificate Services (AD CS) and issue smart cards or virtual smart cards.
- For Tier 1 and Tier 2, use Windows Hello for Business or integrate with a third‑party MFA solution for RDP access (e.g., Duo Security).
- Configure Group Policy:
Interactive logon: Require smart card→ Enabled for admin accounts (use Group Policy filtering).
- Logon Restrictions:
- Logon Workstations: Restrict Tier 0 admin accounts to specific PAWs. Use the
userWorkstationsattribute. Example:Set-ADUser jdoe_t0 -LogonWorkstations "PAW-JDOE-01,PAW-JDOE-02". - Logon Hours: Restrict logon hours to business hours where feasible. Use ADUC or PowerShell:
Set-ADUser jdoe_t0 -LogonHours (New-Object byte[] 21)(complex, but can be scripted).
- Logon Workstations: Restrict Tier 0 admin accounts to specific PAWs. Use the
- Just‑In‑Time (JIT) Administration:
- Implement a PAM solution (e.g., Microsoft Identity Manager PAM, Azure AD PIM, or third‑party) to grant temporary privileged access.
- If a full PAM solution is not feasible, consider using scheduled scripts to add users to privileged groups for limited durations, with proper approval workflows.
- Audit all JIT activations and alert on any activations outside approved hours or without approval.
- Regular Auditing of Privileged Groups:
- Run a weekly script to list members of Domain Admins, Enterprise Admins, Schema Admins, and other sensitive groups. Compare against an approved list.
- Alert on any unauthorised additions.
- Use tools like
Get-ADGroupMemberand export to CSV for review.
3. Authentication Policies – Strengthening the First Line of Defence
- Password Policies (Fine‑Grained):
- Create separate Password Settings Objects (PSOs) for different user tiers. For example:
- Standard users: Minimum 12 characters, complexity enabled, history 24, max age 90 days (modern guidance suggests removing mandatory expiry, but compliance may require it).
- Admins: Minimum 16‑20 characters, complexity enabled, history 24, max age 30‑60 days.
- Service accounts: Minimum 20 characters, complexity enabled, history 24, no expiry (if using gMSAs, they handle their own rotation).
- Apply PSOs using ADAC or PowerShell:
Add-ADFineGrainedPasswordPolicySubject -Identity "AdminPSO" -Subjects "cn=Admins,ou=Groups,dc=contoso,dc=com".
- Create separate Password Settings Objects (PSOs) for different user tiers. For example:
- Account Lockout Policies:
- Set account lockout threshold to 5‑10 invalid attempts.
- Set lockout duration to 30‑60 minutes (or 0 for manual unlock in high‑security environments).
- Set reset counter after 30‑60 minutes.
- Monitor lockout events (Event ID 4740) to identify potential brute‑force attacks.
- Kerberos Policy:
- Enforce AES encryption: Set
Network security: Configure encryption types allowed for KerberostoAES128_HMAC_SHA1andAES256_HMAC_SHA1. Uncheck RC4 and DES. - Reduce ticket lifetimes: Set
Maximum lifetime for service ticketto 600 minutes (10 hours) or less.Maximum lifetime for user ticketto 10 hours.Maximum lifetime for user ticket renewalto 7 days. - Enable Kerberos armoring (FAST) if all clients support it (Windows 8/2012+).
- Enforce AES encryption: Set
- NTLM Restriction:
- Follow the phased approach in 6.2: audit → restrict → deny.
- Use Group Policy:
Network security: Restrict NTLM: Incoming NTLM traffic→ start with "Deny all domain accounts" after thorough testing. - Monitor Event ID 8005 (NTLM rejection) to identify any broken applications.
4. Group Policy Security Settings – Hardening the OS
Group Policy is the primary tool for configuring security settings on domain‑joined machines. The following settings should be applied at appropriate levels (domain, OU).
- User Account Control (UAC):
User Account Control: Run all administrators in Admin Approval Mode→ Enabled.User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode→ "Prompt for consent on the secure desktop" (or "Prompt for credentials" for higher security).User Account Control: Only elevate executables that are signed and validated→ Enabled (optional, may break some apps).
- Network Access and Security:
Network access: Do not allow anonymous enumeration of SAM accounts and shares→ Enabled.Network access: Restrict anonymous access to Named Pipes and Shares→ Enabled.Network security: Do not store LAN Manager hash value on next password change→ Enabled.Network security: LAN Manager authentication level→ "Send NTLMv2 response only. Refuse LM & NTLM".Microsoft network client: Digitally sign communications (always)→ Enabled (for all domain members).Microsoft network server: Digitally sign communications (always)→ Enabled (especially on servers).
- Windows Firewall:
- Enable Windows Firewall with Advanced Security via GPO for all profiles (Domain, Private, Public).
- Create inbound rules to allow only necessary traffic (e.g., RDP from management subnets, file sharing from authorised clients).
- Block all inbound traffic by default and create explicit allow rules.
5. Local Administrator Password Solution (LAPS) – Eliminating Shared Local Admin
LAPS is a critical control to prevent lateral movement using local admin credentials. Implement it on all workstations and servers.
- Installation and Configuration:
- Download LAPS from Microsoft and install on management workstations.
- Extend the AD schema: Run
Update-LapsADSchemain an elevated PowerShell session on a DC. - Delegate permissions to computer objects so that machines can update their own
ms-Mcs-AdmPwdattribute. Use theSet-LapsADComputerSelfPermissioncmdlet. - Create a GPO to deploy the LAPS client. The GPO should be linked to OUs containing computers.
- Configure LAPS policy in the GPO:
Computer Configuration → Administrative Templates → LAPS- Set "Enable local admin password management" to Enabled.
- Configure password settings: complexity, length (recommended 14+ characters), and expiration (e.g., 30 days).
- Delegate read access to the password attribute (
ms-Mcs-AdmPwd) to authorised helpdesk groups. - Test on a pilot OU before broad deployment.
- Monitoring LAPS:
- Monitor Event ID 10003 (password successfully changed) and 10004 (password retrieval) on clients.
- Audit access to LAPS passwords via AD auditing (enable success/failure on the
ms-Mcs-AdmPwdattribute). - Periodically verify that all machines have a valid LAPS password (report using
Get-LapsADPassword).
6. Monitoring and Auditing – Visibility is Security
You cannot defend what you cannot see. Comprehensive monitoring and auditing are essential for detecting attacks in progress and investigating incidents.
- Enable Advanced Audit Policies: Use Group Policy to configure the following audit settings (at minimum):
Category Subcategory Setting Account Logon Audit Kerberos Authentication Service Success, Failure Account Logon Audit Kerberos Service Ticket Operations Success, Failure Account Logon Audit Credential Validation Success, Failure Account Management Audit User Account Management Success, Failure Account Management Audit Security Group Management Success, Failure Account Management Audit Computer Account Management Success, Failure DS Access Audit Directory Service Access Success, Failure DS Access Audit Directory Service Changes Success, Failure DS Access Audit Directory Service Replication Success, Failure Logon/Logoff Audit Logon Success, Failure Logon/Logoff Audit Special Logon Success, Failure Privilege Use Audit Sensitive Privilege Use Success, Failure - Centralised Log Collection:
- Deploy a SIEM (e.g., Azure Sentinel, Splunk, QRadar) and configure all domain controllers and critical servers to forward security logs.
- Use Windows Event Forwarding (WEF) if a SIEM is not immediately available, but a SIEM is strongly recommended for correlation and alerting.
- Retain logs for at least one year (or as required by compliance).
- Critical Event IDs to Monitor and Alert:
Event ID Description Alert Condition 4662 An operation was performed on an object. When object type is Domain‑DNS and access includes DS‑Replication‑Get‑Changes (DCSync detection). 4672 Special privileges assigned to new logon. Any occurrence for a user who should not have admin privileges. 4720 A user account was created. Any account creation, especially outside business hours. 4728/4732/4756 Member added to security group. Addition to any privileged group (Domain Admins, etc.). 4768 A Kerberos authentication ticket (TGT) was requested. Requests for sensitive accounts from unusual sources; requests with long lifetimes. 4769 A Kerberos service ticket was requested. Multiple requests from same user for different SPNs (Kerberoasting). 4776 The domain controller attempted to validate the credentials for an account. NTLM failures for admin accounts. 4740 A user account was locked out. Multiple lockouts may indicate brute‑force. 5136/5137/5141 Directory service object modified/created/deleted. Changes to critical objects (AdminSDHolder, Domain Controllers OU). - Threat Hunting with BloodHound:
- Regularly run BloodHound (or its open‑source alternatives) to map attack paths in your AD. Use the collected data to identify and remediate:
- Over‑privileged users and groups.
- Shortest paths to Domain Admin.
- Kerberoastable accounts with weak passwords.
- Unconstrained delegation endpoints.
- Integrate BloodHound into your regular security assessment cycle (e.g., quarterly).
- Use the
BloodHound-CE(Community Edition) or enterprise versions for continuous monitoring.
- Regularly run BloodHound (or its open‑source alternatives) to map attack paths in your AD. Use the collected data to identify and remediate:
7. Regular Security Assessments – Staying Ahead of Attackers
- Penetration Testing:
- Engage third‑party experts to conduct annual (or more frequent) penetration tests focused on Active Directory.
- Ensure the test includes attempts to exploit the techniques covered in section 6.5 (PtH, Golden Ticket, Kerberoasting, etc.).
- Remediate findings promptly and retest.
- Automated Assessment Tools:
- PingCastle: Run PingCastle regularly (e.g., monthly) to generate an AD security report. Focus on the "Health Check" and "CART" (risk analysis). Address indicators with high risk scores.
- Purple Knight: Another excellent free tool that provides a comprehensive security assessment and prioritised recommendations.
- Microsoft Security Compliance Toolkit: Use the included "Policy Analyzer" to compare your GPOs against Microsoft's security baselines.
- Account and Group Cleanup:
- Quarterly review of all user accounts: disable and remove accounts for former employees, contractors, and inactive users.
- Review group memberships, especially nested groups. Remove users from groups they no longer need.
- Identify and disable service accounts with weak passwords or excessive privileges. Migrate to gMSAs where possible.
- Backup and Disaster Recovery Validation:
- Perform regular (e.g., monthly) test restores of a domain controller from backup. Verify that you can perform an authoritative restore if needed.
- Store backups offline or in an immutable format to protect against ransomware.
- Document and practice the procedure for recovering a domain if all DCs are lost.
8. SMB Hardening – Closing a Major Attack Vector
Server Message Block (SMB) is a common target for attackers. Proper hardening is essential.
- Disable SMBv1:
- SMBv1 is ancient and insecure. Disable it on all systems via Group Policy (Windows Server 2012+ and Windows 8+).
- Use PowerShell:
Set-SmbServerConfiguration -EnableSMB1Protocol $falseon servers, andDisable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol"on clients. - Monitor for any systems that still have SMBv1 enabled (vulnerability scanners can detect this).
- Enable SMB Signing:
- SMB signing ensures integrity and prevents relay attacks. Enable it on all domain controllers and critical servers.
- Group Policy:
Microsoft network server: Digitally sign communications (always)→ Enabled. - For clients, enable
Microsoft network client: Digitally sign communications (always)to require signing for outgoing connections.
- Block SMB at Firewalls:
- At the perimeter firewall, block outbound SMB ports (TCP 139, 445) to prevent data exfiltration and SMB relay to external hosts.
- On internal firewalls, restrict SMB traffic to only necessary communication paths (e.g., between workstations and file servers).
- Enable SMB Encryption:
- For Windows Server 2012+ and Windows 8+, you can require SMB encryption for specific shares or for all traffic. This provides confidentiality and integrity.
- Use PowerShell:
Set-SmbShare -Name "ShareName" -EncryptData $true.
9. DNS Security – Protecting the Locator Service
DNS is critical for AD functionality and can be attacked in various ways (e.g., DNS spoofing, cache poisoning, tunnelling).
- DNSSEC:
- Implement DNSSEC for your Active Directory‑integrated DNS zones to ensure data integrity and authenticity.
- This is complex to deploy but provides strong protection against DNS spoofing.
- Secure Dynamic Updates:
- Configure all AD‑integrated zones to allow only secure dynamic updates. This ensures that only authenticated computers can register their own records.
- In DNS Manager, right‑click zone → Properties → General → Dynamic updates → "Secure only".
- DNS Logging and Monitoring:
- Enable DNS debug logging on domain controllers (carefully, as it can be verbose). Monitor for:
- Queries for unusual domains (potential data exfiltration via DNS tunnelling).
- High volumes of failed queries (possible reconnaissance).
- Queries for known malicious domains (use threat intelligence feeds).
- Forward DNS logs to your SIEM for correlation.
- Enable DNS debug logging on domain controllers (carefully, as it can be verbose). Monitor for:
- Restrict Zone Transfers:
- Limit zone transfers to only authorised DNS servers (typically only other domain controllers).
- In DNS Manager, zone properties → Zone Transfers → "Only to servers listed on the Name Servers tab".
📈 Continuous Improvement – The Security Lifecycle
Security is not a destination but a continuous cycle. Establish a regular cadence for the following activities:
- Weekly: Review alerts from SIEM, check for unusual logon patterns, verify backup success.
- Monthly: Run PingCastle or Purple Knight, review privileged group memberships, audit LAPS password health.
- Quarterly: Conduct a full AD security assessment (including BloodHound), review and update security policies, perform a test restore.
- Annually: Engage external penetration testers, review and update the AD hardening checklist, provide security training to administrators.
🔁 Integrating with Incident Response
Hardening and monitoring must be integrated with your incident response (IR) plan. Ensure that:
- IR playbooks include specific steps for AD compromise scenarios (e.g., Golden Ticket, DCSync).
- The IR team has access to SIEM and can quickly query AD logs.
- There is a clear process for rotating the KRBTGT password in case of suspected compromise.
- Communication channels are established with the AD administration team for rapid response.
📊 Sample Hardening Roadmap
Here's a phased roadmap to implement these best practices in a typical environment:
| Phase | Activities | Timeline |
|---|---|---|
| Phase 1: Foundation |
|
Months 1‑3 |
| Phase 2: Identity Hardening |
|
Months 4‑9 |
| Phase 3: Advanced Controls |
|
Months 10‑18 |
| Phase 4: Continuous Improvement |
|
Ongoing |
Active Directory is the identity backbone of your organisation. Hardening it requires a layered approach: protect the infrastructure, restrict administrative privileges, monitor everything, and continuously assess. The practices in this module, when implemented consistently, will dramatically reduce the risk of a catastrophic AD compromise. Remember that security is a journey, not a destination – stay vigilant, stay informed, and never stop improving.
🎓 Module 06 : Active Directory Security Hardening Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 07 : PowerShell & Active Directory Automation
This module provides a comprehensive deep dive into using PowerShell for Active Directory automation. PowerShell is the primary tool for managing AD at scale – from creating users and groups to querying objects and automating bulk operations. You will learn how to install the AD PowerShell module, create and manage users individually and in bulk, query AD objects using advanced filtering, and automate group management. By the end of this module, you will be equipped to write efficient, production‑ready scripts that save time and reduce errors.
7.1 Installing the Active Directory PowerShell Module
📦 What is the Active Directory PowerShell Module?
The Active Directory PowerShell module is a collection of cmdlets (pronounced "command-lets") that allow administrators to manage Active Directory objects from the PowerShell command line or scripts. It provides a powerful, scriptable interface to perform virtually any task that can be done through the GUI – and many that cannot. The module is part of the Remote Server Administration Tools (RSAT) and is available on Windows Server (with the AD DS role) and on Windows client operating systems (with RSAT installed).
PowerShell enables automation, repeatability, and scalability. A single script can create hundreds of users, update attributes for thousands of objects, or generate complex reports – tasks that would take hours or days manually.
🔧 Installation on Windows Server (with AD DS Role)
If the server is already a domain controller (or has the AD DS role installed), the PowerShell module is installed automatically. However, you may need to import it or ensure the feature is enabled.
Steps:
- Open Server Manager.
- Click Add roles and features.
- Proceed through the wizard until you reach the Features page.
- Expand Remote Server Administration Tools → Role Administration Tools → AD DS and AD LDS Tools.
- Check Active Directory module for Windows PowerShell.
- Complete the installation.
Using PowerShell to install the feature:
# Install the AD PowerShell module on a server (requires administrator privileges)
Install-WindowsFeature -Name RSAT-AD-PowerShell
# Verify installation
Get-Module -Name ActiveDirectory -ListAvailable
After installation, you can import the module into your current session with Import-Module ActiveDirectory. However, the module is typically auto‑loaded when you use any AD cmdlet.
💻 Installation on Windows Client (Windows 10/11)
On client operating systems, you need to install RSAT (Remote Server Administration Tools) and then enable the AD PowerShell module.
Method 1: Via Settings (Windows 10 v1809+ / Windows 11)
- Open Settings → Apps → Optional features.
- Click Add a feature.
- Search for RSAT: Active Directory Domain Services and Lightweight Directory Services Tools.
- Select it and click Install.
Method 2: Via PowerShell (as Administrator)
# For Windows 10/11 (modern versions)
Add-WindowsCapability -Name "Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0" -Online
# For older Windows 10 versions, you might need to download RSAT separately
After installation, the module is available. You can verify by running:
Get-Command -Module ActiveDirectory | Measure-Object
This should show over 100 available cmdlets.
🧪 Testing the Module
Once installed, test that the module works and can connect to your domain:
# Import the module (if not auto-loaded)
Import-Module ActiveDirectory
# Get basic domain information
Get-ADDomain
# Get a specific user (e.g., administrator)
Get-ADUser Administrator
If you receive errors, check that:
- You are running PowerShell as an administrator (for some operations).
- The computer is domain‑joined or you have specified alternate credentials.
- DNS resolution is working and you can reach a domain controller.
🔄 Updating the Module
The AD PowerShell module is updated with Windows updates and new RSAT versions. To ensure you have the latest version, keep your operating system updated. You can check the module version with:
Get-Module ActiveDirectory | Select-Object Version
🔐 Permissions Required
To use AD cmdlets effectively, your account needs appropriate permissions in Active Directory. Common requirements:
- Read operations: Most read cmdlets work for any authenticated user (unless restricted).
- Create/delete/modify users and groups: Requires delegated permissions on the target OUs, or membership in appropriate groups (e.g., Account Operators, Domain Admins).
- High‑privilege operations: Changing domain‑wide settings may require Domain Admin or Enterprise Admin rights.
When scripting, consider using -Credential parameter to specify a service account with the necessary permissions.
7.2 Creating Users via PowerShell – From Basics to Advanced
👤 The New-ADUser Cmdlet
The New-ADUser cmdlet is the primary tool for creating user objects. It has dozens of parameters to set all common user attributes. Mastering this cmdlet is essential for efficient user provisioning.
Basic User Creation
The simplest user creation requires only a few parameters:
New-ADUser -Name "John Smith" -SamAccountName "jsmith" -UserPrincipalName "jsmith@contoso.com" -GivenName "John" -Surname "Smith" -Path "OU=Users,OU=Sales,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "P@ssw0rd123" -AsPlainText -Force) -Enabled $true
Parameter breakdown:
-Name– The display name (also sets the CN).-SamAccountName– The pre‑Windows 2000 logon name (max 20 characters).-UserPrincipalName– The modern logon name (user@domain).-GivenNameand-Surname– First and last name.-Path– The OU where the user will be created.-AccountPassword– A secure string representing the password. Must be converted from plaintext.-Enabled $true– Enables the account immediately. Without this, the account is created but disabled.
Important: Always use ConvertTo-SecureString to handle passwords securely. Avoid storing plaintext passwords in scripts.
Setting Additional Attributes
New-ADUser supports many common attributes directly as parameters:
New-ADUser -Name "Jane Doe" -SamAccountName "jdoe" -UserPrincipalName "jdoe@contoso.com" -GivenName "Jane" -Surname "Doe" -Path "OU=Users,OU=IT,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "P@ssw0rd456" -AsPlainText -Force) -Enabled $true -Department "IT" -Title "Network Engineer" -Company "Contoso Ltd." -Office "London" -PhoneNumber "+44 20 1234 5678" -EmailAddress "jane.doe@contoso.com" -Manager "CN=John Smith,OU=Users,OU=Sales,DC=contoso,DC=com"
Using Splatting for Readability
For complex user creation with many parameters, use splatting to improve readability and maintainability:
$userParams = @{
Name = "Robert Johnson"
SamAccountName = "rjohnson"
UserPrincipalName = "rjohnson@contoso.com"
GivenName = "Robert"
Surname = "Johnson"
Path = "OU=Users,OU=Finance,DC=contoso,DC=com"
AccountPassword = (ConvertTo-SecureString "P@ssw0rd789" -AsPlainText -Force)
Enabled = $true
Department = "Finance"
Title = "Accountant"
Company = "Contoso Ltd."
Office = "New York"
PhoneNumber = "+1 212 555 1234"
EmailAddress = "robert.johnson@contoso.com"
Manager = "CN=Jane Doe,OU=Users,OU=IT,DC=contoso,DC=com"
StreetAddress = "123 Main St"
City = "New York"
State = "NY"
PostalCode = "10001"
Country = "US"
}
New-ADUser @userParams
Creating Users with Custom Attributes
If you need to set attributes that are not directly available as parameters, use the -OtherAttributes parameter with a hashtable:
New-ADUser -Name "Alice Wonder" -SamAccountName "awonder" -UserPrincipalName "awonder@contoso.com" -Path "OU=Users,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "P@ssw0rdABC" -AsPlainText -Force) -Enabled $true -OtherAttributes @{
extensionAttribute1 = "Employee123"
employeeID = "EMP001"
employeeNumber = "12345"
wWWHomePage = "http://internal/employees/alice"
}
Setting Password and Account Options
Control account behaviour with additional parameters:
-ChangePasswordAtLogon $true– Forces user to change password at next logon.-PasswordNeverExpires $true– Sets the password to never expire (use with caution).-CannotChangePassword $true– Prevents user from changing their own password.-AccountNotDelegated $true– Account is sensitive and cannot be delegated.
New-ADUser -Name "Temp User" -SamAccountName "tempuser" -UserPrincipalName "tempuser@contoso.com" -Path "OU=Users,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "TempP@ss" -AsPlainText -Force) -Enabled $true -ChangePasswordAtLogon $true -PasswordNeverExpires $false
Creating Users in Different Domains or with Alternate Credentials
Use the -Server parameter to target a specific domain controller, and -Credential to run as a different user:
$cred = Get-Credential "CONTOSO\svc_powershell"
New-ADUser -Name "Remote User" -SamAccountName "remoteuser" -UserPrincipalName "remoteuser@contoso.com" -Path "OU=Users,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "RemoteP@ss" -AsPlainText -Force) -Enabled $true -Server "dc02.contoso.com" -Credential $cred
Error Handling and Validation
When scripting user creation, always include error handling to avoid script termination on errors:
try {
New-ADUser -Name "Test User" -SamAccountName "testuser" -UserPrincipalName "testuser@contoso.com" -Path "OU=Users,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "TestP@ss" -AsPlainText -Force) -Enabled $true -ErrorAction Stop
Write-Host "User created successfully." -ForegroundColor Green
} catch {
Write-Warning "Failed to create user: $($_.Exception.Message)"
}
Creating Users with Home Folders and Profile Paths
You can set home directories and profile paths during creation, but note that the actual folder creation on the file server must be handled separately (e.g., with New-Item or by a separate script).
New-ADUser -Name "User With Home" -SamAccountName "uwh" -UserPrincipalName "uwh@contoso.com" -Path "OU=Users,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "HomeP@ss" -AsPlainText -Force) -Enabled $true -HomeDrive "H:" -HomeDirectory "\\fileserver\homes\uwh" -ProfilePath "\\fileserver\profiles\uwh"
7.3 Bulk User Import via CSV – Automating Large‑Scale Provisioning
📊 The Power of CSV Import
In real‑world scenarios, you rarely create users one by one. Instead, you receive data from HR systems, spreadsheets, or other sources in CSV (Comma‑Separated Values) format. PowerShell excels at processing CSV files and creating AD users in bulk, saving countless hours and eliminating manual errors.
📁 Preparing the CSV File
A well‑structured CSV file is essential. Typically, each column corresponds to a user attribute. For example:
FirstName,LastName,SamAccountName,UPN,Department,Title,ManagerEmail,Password
John,Smith,jsmith,jsmith@contoso.com,Sales,Manager,jdoe@contoso.com,P@ssw0rd1
Jane,Doe,jdoe,jdoe@contoso.com,IT,Engineer,jsmith@contoso.com,P@ssw0rd2
Bob,Johnson,bjohnson,bjohnson@contoso.com,Finance,Accountant,jdoe@contoso.com,P@ssw0rd3
Tips for CSV preparation:
- Include all required attributes: at minimum, Name, SamAccountName, and UPN.
- Use friendly column names that map directly to parameters.
- Ensure passwords are handled securely – consider generating random passwords in the script instead of storing them in the CSV.
- Include a column for OU Path if users go to different OUs.
🔄 Basic Bulk Import Script
The simplest bulk import uses Import-Csv and a loop:
# Import the CSV file
$users = Import-Csv -Path "C:\scripts\newusers.csv"
# Loop through each row and create the user
foreach ($user in $users) {
try {
New-ADUser -Name "$($user.FirstName) $($user.LastName)" `
-SamAccountName $user.SamAccountName `
-UserPrincipalName $user.UPN `
-GivenName $user.FirstName `
-Surname $user.LastName `
-Department $user.Department `
-Title $user.Title `
-Path "OU=Users,OU=$($user.Department),DC=contoso,DC=com" `
-AccountPassword (ConvertTo-SecureString $user.Password -AsPlainText -Force) `
-Enabled $true `
-ChangePasswordAtLogon $true `
-ErrorAction Stop
Write-Host "Created user: $($user.SamAccountName)" -ForegroundColor Green
} catch {
Write-Warning "Failed to create user $($user.SamAccountName): $($_.Exception.Message)"
}
}
🔐 Generating Random Passwords
Storing passwords in a CSV is insecure. A better approach is to generate random strong passwords during the import and save them to a secure file for distribution.
# Function to generate a random password
function Generate-RandomPassword {
param(
[int]$Length = 14
)
Add-Type -AssemblyName System.Web
return [System.Web.Security.Membership]::GeneratePassword($Length, 2)
}
$users = Import-Csv -Path "C:\scripts\newusers.csv"
$passwordLog = @()
foreach ($user in $users) {
$password = Generate-RandomPassword
try {
New-ADUser -Name "$($user.FirstName) $($user.LastName)" `
-SamAccountName $user.SamAccountName `
-UserPrincipalName "$($user.SamAccountName)@contoso.com" `
-GivenName $user.FirstName `
-Surname $user.LastName `
-Department $user.Department `
-Title $user.Title `
-Path "OU=Users,OU=$($user.Department),DC=contoso,DC=com" `
-AccountPassword (ConvertTo-SecureString $password -AsPlainText -Force) `
-Enabled $true `
-ChangePasswordAtLogon $true `
-ErrorAction Stop
# Log the password securely (this file should be protected)
$passwordLog += [PSCustomObject]@{
SamAccountName = $user.SamAccountName
Password = $password
}
Write-Host "Created user: $($user.SamAccountName)" -ForegroundColor Green
} catch {
Write-Warning "Failed to create user $($user.SamAccountName): $($_.Exception.Message)"
}
}
# Export password log to encrypted file (or store securely)
$passwordLog | Export-Csv -Path "C:\scripts\passwords.csv" -NoTypeInformation
Important: The password log must be stored securely (encrypted, restricted access) and ideally delivered to managers via a secure channel. Consider using Protect-CmsMessage for encryption.
🏢 Handling Multiple OUs
If users belong to different departments or locations, include an OU column in the CSV:
FirstName,LastName,SamAccountName,Department,OUPath
John,Smith,jsmith,Sales,"OU=Sales,OU=Users,DC=contoso,DC=com"
Jane,Doe,jdoe,IT,"OU=IT,OU=Users,DC=contoso,DC=com"
Then in the script:
New-ADUser -Name "$($user.FirstName) $($user.LastName)" -Path $user.OUPath ...
🔗 Setting Manager Relationships
If your CSV includes manager information (e.g., by SamAccountName or email), you can set the manager attribute after creation, or during creation if you have the manager's Distinguished Name.
# Assuming CSV has a "ManagerSam" column
$manager = Get-ADUser -Identity $user.ManagerSam
Set-ADUser -Identity $user.SamAccountName -Manager $manager.DistinguishedName
For bulk operations, it's more efficient to set manager after all users are created, using a second loop.
📈 Advanced: Adding Users to Groups
Often, new users need to be added to standard groups (e.g., "All Employees", "VPN Users"). Extend the script to handle group memberships:
# After creating the user, add to default groups
$defaultGroups = @("All Employees", "VPN Users", "Company Communications")
foreach ($group in $defaultGroups) {
try {
Add-ADGroupMember -Identity $group -Members $user.SamAccountName -ErrorAction Stop
Write-Host " Added to group: $group" -ForegroundColor Yellow
} catch {
Write-Warning " Failed to add to group $group : $($_.Exception.Message)"
}
}
🛡️ Error Handling and Logging
For production scripts, comprehensive logging is essential. Create a log file with success/failure details:
$logFile = "C:\scripts\user_creation_log_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt"
$users = Import-Csv -Path "C:\scripts\newusers.csv"
foreach ($user in $users) {
$status = "Success"
$message = ""
try {
# ... user creation code ...
} catch {
$status = "Failed"
$message = $_.Exception.Message
}
# Write to log
"$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss'),$($user.SamAccountName),$status,$message" | Out-File -FilePath $logFile -Append
}
🚀 Real‑World Example: HR Integration Script
A typical HR integration script might:
- Download a CSV from an HR system (e.g., Workday, SAP) via API or SFTP.
- Validate the data (check for missing required fields).
- Generate random passwords.
- Create user accounts in the appropriate OUs.
- Set manager relationships (by looking up manager employee ID).
- Add users to standard groups based on department/location.
- Create home directories on a file server.
- Send an email to the manager with the username and password.
- Log all actions and report on success/failure.
Such a script can be scheduled to run daily, ensuring new hires are provisioned automatically.
7.4 Querying AD Objects – Get‑ADUser, Get‑ADGroup, Get‑ADComputer
🔍 The Get‑AD* Cmdlet Family
The ability to query Active Directory efficiently is fundamental to automation, reporting, and troubleshooting. PowerShell provides a set of Get‑ cmdlets for each major object type: Get-ADUser, Get-ADGroup, Get-ADComputer, Get-ADOrganizationalUnit, and more. These cmdlets support powerful filtering, property selection, and searching across the directory.
Basic Usage – Get-ADUser
The simplest query retrieves a single user by identity:
Get-ADUser -Identity jsmith
By default, only a few attributes are returned. To get all attributes, use -Properties *:
Get-ADUser -Identity jsmith -Properties *
To get specific attributes:
Get-ADUser -Identity jsmith -Properties Department, Title, Manager, LastLogonDate
Filtering with the -Filter Parameter
The -Filter parameter is the most flexible way to query multiple objects. It uses a PowerShell expression language similar to the Where-Object syntax.
Common filter examples:
# All users in the Sales department
Get-ADUser -Filter "Department -eq 'Sales'"
# Users created in the last 7 days
$cutoff = (Get-Date).AddDays(-7)
Get-ADUser -Filter "Created -ge '$cutoff'"
# Users who have never logged on (LastLogonDate is null)
Get-ADUser -Filter "LastLogonDate -notlike '*'"
# Users with a specific title
Get-ADUser -Filter "Title -like '*Manager*'"
# Users in a specific OU (using SearchBase)
Get-ADUser -Filter * -SearchBase "OU=Sales,OU=Users,DC=contoso,DC=com"
# Users who are enabled
Get-ADUser -Filter "Enabled -eq 'True'"
# Users with password never expires
Get-ADUser -Filter "PasswordNeverExpires -eq 'True'" -Properties PasswordNeverExpires
Filter syntax notes:
- Use single quotes around string values.
- Operators:
-eq,-ne,-like,-notlike,-ge,-le,-and,-or,-not. - For boolean attributes, use
'True'or'False'as strings. - For dates, use a string representation that PowerShell can convert.
Using LDAP Filters
For complex queries or performance, you can use traditional LDAP filters with the -LDAPFilter parameter:
Get-ADUser -LDAPFilter "(&(objectCategory=person)(objectClass=user)(department=Sales))"
This is particularly useful when you need to use LDAP matching rules or when working with tools that generate LDAP filters.
Selecting Properties and Formatting Output
Use Select-Object to choose specific properties for display or export:
Get-ADUser -Filter "Department -eq 'Sales'" -Properties Department, Title, LastLogonDate | Select-Object Name, SamAccountName, Department, Title, LastLogonDate
For CSV export, pipe directly to Export-Csv:
Get-ADUser -Filter * -Properties Department, Title | Select-Object Name, SamAccountName, Department, Title | Export-Csv -Path "C:\reports\all_users.csv" -NoTypeInformation
Querying Groups – Get-ADGroup and Get-ADGroupMember
To get group information:
# Get a specific group
Get-ADGroup -Identity "Domain Admins"
# Get all groups in a specific OU
Get-ADGroup -Filter * -SearchBase "OU=Groups,DC=contoso,DC=com"
# Get group membership (recursive)
Get-ADGroupMember -Identity "Domain Admins" -Recursive
# Get group membership including nested groups as objects
Get-ADGroupMember -Identity "Sales Team" | Get-ADUser -Properties Department
Querying Computers – Get-ADComputer
# Get all computers in a specific OU
Get-ADComputer -Filter * -SearchBase "OU=Workstations,OU=Computers,DC=contoso,DC=com"
# Find computers with a specific operating system
Get-ADComputer -Filter "OperatingSystem -like '*Windows 10*'" -Properties OperatingSystem
# Find computers that haven't logged on in 90 days
$cutoff = (Get-Date).AddDays(-90)
Get-ADComputer -Filter "LastLogonDate -lt '$cutoff'" -Properties LastLogonDate | Select-Object Name, LastLogonDate
Advanced Queries with Calculated Properties
You can create calculated properties to transform data on the fly:
Get-ADUser -Filter "Enabled -eq 'True'" -Properties LastLogonDate, PasswordLastSet | Select-Object Name, SamAccountName, @{Name='LastLogon'; Expression={$_.LastLogonDate}}, @{Name='PasswordAge'; Expression={ if ($_.PasswordLastSet) { (Get-Date) - $_.PasswordLastSet } else { 'Never' } }}
Performance Considerations
- Avoid -Properties * if possible: Requesting all attributes generates more network traffic and slows down queries. Request only the properties you need.
- Use filtering at the source: The
-Filterparameter is more efficient than retrieving all objects and then usingWhere-Object. The filter is processed by the domain controller. - Page size: For very large result sets, use
-ResultPageSize(default 256) to control how many objects are returned per page. - Search scope: Use
-SearchBaseto limit the search to a specific OU, reducing the search space.
Exporting to Different Formats
# Export to CSV
Get-ADUser -Filter * -Properties Department | Select-Object Name, SamAccountName, Department | Export-Csv users.csv -NoTypeInformation
# Export to HTML (simple report)
Get-ADUser -Filter "Department -eq 'Sales'" -Properties Department, Title | Select-Object Name, SamAccountName, Title | ConvertTo-Html | Out-File sales_users.html
# Export to JSON (for integration with other systems)
Get-ADUser -Filter * -Properties Department | Select-Object Name, SamAccountName, Department | ConvertTo-Json | Out-File users.json
Using the AD Drive (AD:)
The Active Directory provider creates a PS drive AD: that lets you navigate AD like a file system. This can be useful for exploring and for simple scripts.
# Navigate to the domain root
cd AD:
# List OUs and containers
dir
# Navigate into an OU
cd "OU=Sales,DC=contoso,DC=com"
# Get user objects in the current path
dir
However, for scripting, the Get‑ cmdlets are generally more powerful and flexible.
ForEach-Object and Where-Object to perform complex data manipulation. For example, to disable all users who haven't logged on in 90 days: Get-ADUser -Filter "LastLogonDate -lt '$cutoff'" | Disable-ADAccount.
7.5 Automating Group Management – Adding, Removing, and Reporting
👥 The Importance of Group Automation
Group management is one of the most frequent administrative tasks. Users join and leave teams, project memberships change, and access requirements evolve. Manual group management is error‑prone and time‑consuming. PowerShell enables you to automate group membership based on rules, schedule clean‑up tasks, and generate compliance reports.
Adding Users to Groups
The Add-ADGroupMember cmdlet adds one or more members to a group.
# Add a single user to a group
Add-ADGroupMember -Identity "Sales Team" -Members "jsmith"
# Add multiple users
Add-ADGroupMember -Identity "Sales Team" -Members "jsmith", "jdoe", "bjohnson"
# Add users from a CSV
$users = Import-Csv "C:\scripts\sales_newhires.csv"
foreach ($user in $users) {
Add-ADGroupMember -Identity "Sales Team" -Members $user.SamAccountName
}
Note: The -Members parameter accepts SamAccountName, Distinguished Name, or SID. For bulk adds, using SamAccountName is convenient.
Removing Users from Groups
Use Remove-ADGroupMember similarly:
# Remove a user from a group
Remove-ADGroupMember -Identity "Sales Team" -Members "jsmith" -Confirm:$false
# Remove multiple users
Remove-ADGroupMember -Identity "Sales Team" -Members "jdoe", "bjohnson" -Confirm:$false
The -Confirm:$false suppresses confirmation prompts for automation.
Bulk Group Membership Operations from CSV
A common scenario is a CSV file with two columns: User and Group. You can process this to add or remove memberships.
$memberships = Import-Csv "C:\scripts\group_memberships.csv"
# CSV format: User,Group,Action (Add or Remove)
foreach ($item in $memberships) {
try {
if ($item.Action -eq "Add") {
Add-ADGroupMember -Identity $item.Group -Members $item.User -ErrorAction Stop
Write-Host "Added $($item.User) to $($item.Group)" -ForegroundColor Green
} elseif ($item.Action -eq "Remove") {
Remove-ADGroupMember -Identity $item.Group -Members $item.User -Confirm:$false -ErrorAction Stop
Write-Host "Removed $($item.User) from $($item.Group)" -ForegroundColor Yellow
}
} catch {
Write-Warning "Failed on $($item.User) / $($item.Group): $($_.Exception.Message)"
}
}
Synchronising Group Membership with a Source of Truth
Often, you want a group's membership to exactly match a list from an external system (e.g., HR database, project management tool). The approach is to:
- Get the current group members.
- Get the desired members from the source.
- Add members who are in the desired list but not in the current list.
- Remove members who are in the current list but not in the desired list.
$groupName = "Project X Team"
$desiredMembers = @("jsmith", "jdoe", "bjohnson") # Could come from CSV or API
# Get current members (SamAccountName only)
$currentMembers = Get-ADGroupMember -Identity $groupName | Select-Object -ExpandProperty SamAccountName
# Find members to add (in desired but not current)
$toAdd = $desiredMembers | Where-Object { $_ -notin $currentMembers }
# Find members to remove (in current but not desired)
$toRemove = $currentMembers | Where-Object { $_ -notin $desiredMembers }
# Add new members
foreach ($user in $toAdd) {
Add-ADGroupMember -Identity $groupName -Members $user
Write-Host "Added $user"
}
# Remove departed members
foreach ($user in $toRemove) {
Remove-ADGroupMember -Identity $groupName -Members $user -Confirm:$false
Write-Host "Removed $user"
}
Automating Group Cleanup – Stale Members
Over time, groups accumulate stale members (e.g., users who have left the company or changed roles). A scheduled script can identify and remove these.
# Find users who are disabled but still members of important groups
$disabledUsers = Get-ADUser -Filter "Enabled -eq 'False'" | Select-Object -ExpandProperty SamAccountName
$importantGroups = @("Domain Admins", "Enterprise Admins", "VPN Users")
foreach ($group in $importantGroups) {
$members = Get-ADGroupMember -Identity $group | Select-Object -ExpandProperty SamAccountName
$toRemove = $members | Where-Object { $_ -in $disabledUsers }
foreach ($user in $toRemove) {
Remove-ADGroupMember -Identity $group -Members $user -Confirm:$false
Write-Host "Removed disabled user $user from $group"
}
}
Reporting Group Membership
Regular reports on group membership are essential for audits and access reviews.
# Generate a report of all members of a specific group, with user details
Get-ADGroupMember -Identity "Sales Team" -Recursive | Get-ADUser -Properties Department, Title | Select-Object Name, SamAccountName, Department, Title | Export-Csv "sales_team_report.csv" -NoTypeInformation
# Report on all members of multiple groups
$groups = @("Sales Team", "IT Team", "Finance Team")
$report = @()
foreach ($group in $groups) {
$members = Get-ADGroupMember -Identity $group -Recursive | Get-ADUser -Properties Department
foreach ($member in $members) {
$report += [PSCustomObject]@{
GroupName = $group
UserName = $member.Name
SamAccountName = $member.SamAccountName
Department = $member.Department
}
}
}
$report | Export-Csv "all_group_memberships.csv" -NoTypeInformation
Nested Group Management
Groups can contain other groups. Managing nested groups requires recursion.
# Get all members of a group, including nested groups (recursive)
Get-ADGroupMember -Identity "All Employees" -Recursive | Get-ADUser | Select-Object Name, SamAccountName
# Find all groups that a user is a member of (transitive)
Get-ADUser -Identity jsmith -Properties MemberOf | Select-Object -ExpandProperty MemberOf | Get-ADGroup | Select-Object Name
Creating Groups Automatically
You can create groups based on rules, such as all users in a department.
# Create a group for each department (if not already present)
$departments = Get-ADUser -Filter * -Properties Department | Where-Object { $_.Department } | Select-Object -ExpandProperty Department -Unique
foreach ($dept in $departments) {
$groupName = "Department_$dept"
# Check if group exists
if (-not (Get-ADGroup -Filter "Name -eq '$groupName'" -ErrorAction SilentlyContinue)) {
New-ADGroup -Name $groupName -GroupScope Global -GroupCategory Security -Path "OU=Groups,DC=contoso,DC=com" -Description "All users in $dept department"
Write-Host "Created group $groupName"
}
}
Integrating with Dynamic Groups (via Script)
While Active Directory doesn't have native dynamic groups (unlike Azure AD), you can simulate them with scheduled scripts that update group membership based on user attributes.
# Maintain a group of all users in the Sales department
$groupName = "Sales Department Users"
$salesUsers = Get-ADUser -Filter "Department -eq 'Sales'" | Select-Object -ExpandProperty SamAccountName
$currentMembers = Get-ADGroupMember -Identity $groupName | Select-Object -ExpandProperty SamAccountName
# Add new sales users
$toAdd = $salesUsers | Where-Object { $_ -notin $currentMembers }
foreach ($user in $toAdd) {
Add-ADGroupMember -Identity $groupName -Members $user
}
# Remove non‑sales users
$toRemove = $currentMembers | Where-Object { $_ -notin $salesUsers }
foreach ($user in $toRemove) {
Remove-ADGroupMember -Identity $groupName -Members $user -Confirm:$false
}
This script can be scheduled to run daily, ensuring the group always reflects the current Sales department.
Advanced: Managing Group Membership with Approval Workflow
For higher‑security groups (e.g., Domain Admins), you can implement a JIT (Just‑In‑Time) workflow using PowerShell:
- User submits a request (e.g., via email, web form, or Teams).
- A script processes the request, checks approval, and adds the user to the group for a limited time.
- A scheduled job removes the user after the time expires.
This is complex but achievable with PowerShell, Exchange Web Services, and scheduled tasks.
Error Handling and Logging in Group Management Scripts
As with user creation, always include error handling and logging:
function Add-UserToGroupWithLogging {
param(
[string]$User,
[string]$Group
)
try {
Add-ADGroupMember -Identity $Group -Members $User -ErrorAction Stop
Write-Log -Message "Added $User to $Group" -Level INFO
return $true
} catch {
Write-Log -Message "Failed to add $User to $Group: $($_.Exception.Message)" -Level ERROR
return $false
}
}
🎓 Module 07 : PowerShell & AD Automation Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 08 : Hybrid Active Directory & Microsoft Azure Integration
This module provides a comprehensive deep dive into hybrid identity – the integration of on‑premises Active Directory with Azure Active Directory (Azure AD). As organisations move to the cloud, understanding how to extend your on‑premises identity to Azure is critical. You will learn what Azure AD is, how it differs from traditional AD, the role of Azure AD Connect, single sign‑on (SSO), and how to design a robust hybrid identity architecture. By the end, you will be equipped to plan, implement, and manage a hybrid identity solution that meets modern business and security requirements.
8.1 What is Azure Active Directory (Azure AD)?
☁️ Definition and Purpose
Azure Active Directory (Azure AD) is Microsoft’s cloud‑based identity and access management service. It provides authentication and authorisation for a wide range of Microsoft cloud services, including Microsoft 365, Azure, and thousands of other SaaS applications. Unlike on‑premises Active Directory, which is a directory service for Windows domain networks, Azure AD is designed for the cloud – it is a multi‑tenant, highly available identity platform that supports modern authentication protocols such as OAuth 2.0, OpenID Connect, and SAML.
Think of Azure AD as the identity backbone for the cloud. It’s like a global phonebook and security guard for cloud apps – it knows who you are and what you can access, no matter where you are.
🧩 Key Features of Azure AD
- Identity as a Service (IDaaS): Azure AD provides authentication, single sign‑on (SSO), and multi‑factor authentication (MFA) for cloud applications.
- Multi‑tenant architecture: Each organisation gets a dedicated tenant (a logical container) isolated from others, yet the service is shared across tenants for scalability.
- Application integration: Thousands of pre‑integrated applications (SaaS apps like Salesforce, Dropbox, etc.) can be connected for SSO and provisioning.
- Conditional Access: Policy‑based controls that evaluate signals (user, location, device, risk) to allow or block access.
- Self‑service capabilities: Users can reset passwords, manage groups, and access applications through a portal (My Apps).
- Identity protection and governance: Azure AD Identity Protection detects risks, and Privileged Identity Management (PIM) provides just‑in‑time access.
- Device identity management: Supports Azure AD Join, Hybrid Azure AD Join, and mobile device management (MDM) integration.
🏢 Azure AD Tenants and Subscriptions
An Azure AD tenant is a dedicated instance of Azure AD that is automatically created when your organisation signs up for a Microsoft cloud service (e.g., Microsoft 365, Azure). Each tenant is associated with one or more DNS domains (e.g., contoso.com) and is isolated from other tenants. Within a tenant, you can create users, groups, and applications.
An Azure subscription is a billing and management container for Azure resources. It is trusts an Azure AD tenant for identity. In other words, the subscription uses the tenant to authenticate users who can then manage resources within that subscription. One tenant can have multiple subscriptions, and one subscription is associated with exactly one tenant.
🔐 Licensing – Azure AD Free vs Premium
Azure AD comes in several editions:
- Free: Included with Microsoft 365 or Azure subscriptions. Provides user and group management, on‑premises directory sync, basic SSO, and self‑service password change for cloud users.
- Microsoft Entra ID P1: Adds advanced features like dynamic groups, self‑service password reset (cloud and on‑premises with writeback), Conditional Access, and Microsoft Identity Manager integration.
- Microsoft Entra ID P2: Includes all P1 features plus Azure AD Identity Protection and Privileged Identity Management (PIM).
For hybrid scenarios, at least P1 is recommended to leverage features like password writeback, device writeback, and advanced Conditional Access policies.
🌐 Azure AD vs On‑Premises AD – High‑Level Comparison
While both are identity solutions, they serve different purposes:
- On‑premises AD is for managing Windows devices, servers, and applications in a corporate network. It uses Kerberos, LDAP, and NTLM.
- Azure AD is for cloud applications and services. It uses REST APIs, OAuth, SAML, and OpenID Connect. It does not have OUs, Group Policy, or domains in the traditional sense (instead, it has a flat structure with administrative units).
In a hybrid environment, you synchronise on‑premises AD with Azure AD, giving users a single identity for both on‑premises and cloud resources.
8.2 On‑Premises AD vs Azure AD – Detailed Comparison
🔍 Understanding the Differences
While both are called “Active Directory,” they are fundamentally different products designed for different environments. This section provides a detailed comparison to help you understand when to use each and how they complement each other in a hybrid setup.
📊 Feature Comparison Table
| Feature / Aspect | On‑Premises Active Directory (AD DS) | Azure Active Directory (Azure AD) |
|---|---|---|
| Primary Purpose | Directory service for Windows domain networks – manage users, computers, servers, and resources. | Identity and access management for cloud applications and services (SaaS, Azure, Microsoft 365). |
| Architecture | Hierarchical: forests, domains, OUs. Uses LDAP as primary access protocol. | Flat: tenant with users and groups. REST API / Graph API for access. |
| Authentication Protocols | Kerberos, NTLM, LDAP (simple bind). | OAuth 2.0, OpenID Connect, SAML 2.0, WS‑Federation. |
| Directory Structure | Organizational Units (OUs) for hierarchical management and GPO application. | Flat structure; Administrative Units (preview) provide limited delegation. |
| Group Policy | Powerful Group Policy Objects (GPOs) for managing operating systems and applications. | Device management via Microsoft Intune / MDM policies, not GPO. |
| Device Management | Domain join for Windows devices; Group Policy for configuration. | Azure AD Join, Hybrid Azure AD Join, mobile device management (MDM) with Intune. |
| Application Support | Integrated Windows Authentication for on‑premises apps; LDAP for legacy apps. | SAML, OAuth for cloud/SaaS apps; app proxy for on‑premises apps. |
| Multi‑Factor Authentication | Requires additional infrastructure (e.g., ADFS, Azure MFA server). | Built‑in MFA with Conditional Access. |
| Scalability | Limited by hardware and forest design; can scale to millions of objects. | Virtually unlimited; multi‑tenant cloud service. |
| High Availability | Requires deploying multiple domain controllers across sites. | Built‑in, managed by Microsoft (99.99% SLA). |
| Management Tools | Active Directory Users and Computers, ADSI Edit, PowerShell. | Azure portal, Microsoft Entra admin center, Microsoft Graph PowerShell, CLI. |
| Integration with Microsoft 365 | Not directly; requires Azure AD Connect for sync. | Native – Microsoft 365 uses Azure AD for identity. |
🔗 When to Use Each
- Use On‑Premises AD when:
- You have Windows servers and workstations that need to be domain‑joined and managed via Group Policy.
- You run applications that require Kerberos or LDAP authentication.
- You need to manage resources in a corporate network with complex OU structures.
- Use Azure AD when:
- You need to provide access to cloud applications (Microsoft 365, SaaS apps).
- You want modern authentication with MFA and Conditional Access.
- You need to manage identities for users who primarily use cloud resources.
🔄 The Hybrid Approach
Most organisations today use a hybrid model: they maintain on‑premises AD for internal resources and synchronise identities to Azure AD for cloud access. This gives users a single identity (same username/password) for both worlds, while leveraging the strengths of each platform.
In a hybrid environment, you use Azure AD Connect to synchronise user and group objects from on‑premises AD to Azure AD. You can also enable password hash sync or pass‑through authentication so that users use the same password for cloud services. Additionally, you can configure seamless SSO to automatically sign users in when they are on corporate devices.
8.3 Azure AD Connect – The Bridge Between On‑Prem and Cloud
🔗 What is Azure AD Connect?
Azure AD Connect is Microsoft’s tool for synchronising on‑premises directories (Active Directory) with Azure AD. It is the essential component for hybrid identity. It handles identity synchronisation, optional password hash sync, pass‑through authentication, and federation configuration. Azure AD Connect replaces older sync tools like DirSync and Azure AD Sync.
Azure AD Connect is like a bridge that keeps your on‑premises user database in sync with the cloud. When you create a user in AD, they automatically appear in Azure AD (after sync).
⚙️ Installation and Configuration
Azure AD Connect is installed on a dedicated Windows server (could be a domain‑joined server, not necessarily a DC). The installation wizard guides you through:
- Selecting sync options: Choose between Express Settings (for single AD forest) or Custom Settings.
- Connecting to Azure AD: Provide global admin credentials for your Azure AD tenant.
- Connecting to on‑premises AD: Provide enterprise admin credentials for your on‑premises AD.
- Configuring domain/OU filtering: Choose which domains and OUs to synchronise.
- Identifying users uniquely: Select the source anchor (usually
objectGUID) and user principal name (UPN) attribute. - Optional features: Enable password hash sync, pass‑through authentication, federation, seamless SSO, device writeback, etc.
- Configure sync: Choose whether to start synchronisation immediately.
The sync engine runs every 30 minutes by default, replicating changes from on‑prem AD to Azure AD.
🔄 Synchronisation Scenarios
Azure AD Connect supports three main authentication methods for cloud access:
- Password Hash Synchronization (PHS): Hashes of user passwords are synchronised from on‑prem AD to Azure AD. Users use the same password for cloud services, and Azure AD performs the authentication. This is the simplest to set up and provides fallback for other methods. It also enables leaked credential detection.
- Pass‑Through Authentication (PTA): Password validation is done directly by an on‑premises agent. The password hash never leaves the on‑premises environment. Suitable for organisations with security policies that forbid password hashes in the cloud. Requires installing an agent on one or more servers.
- Federation (with AD FS): Authentication is delegated to an on‑premises federation service (e.g., Active Directory Federation Services). This is the most complex but allows for advanced claims, smart card authentication, and integration with third‑party identity providers.
You can also combine PHS as a backup for PTA or federation.
🛡️ Password Writeback
When enabled, password writeback allows users to change or reset their passwords in the cloud (e.g., via Azure AD SSPR) and have the new password written back to on‑premises AD. This requires Azure AD Premium P1 or P2 and specific permissions. It is a critical feature for a unified self‑service experience.
📁 Device Writeback
Device writeback enables devices registered in Azure AD (via Azure AD Join or Hybrid Join) to be written back to on‑premises AD for conditional access scenarios. This is useful for on‑premises applications that need device‑aware authentication.
🔍 Filtering and Attribute Mapping
You can control which objects are synchronised using:
- Domain/OU filtering: Select specific OUs to sync.
- Attribute filtering: Use rules to filter based on user attributes (e.g., sync only users with a specific department).
- Group filtering: Sync only members of specific groups (less common).
Azure AD Connect also provides a rich attribute mapping editor, allowing you to customise how on‑prem attributes map to Azure AD attributes. This is done through the Synchronization Rules Editor.
🧪 Staging Server and Disaster Recovery
It is recommended to deploy a staging server – a separate Azure AD Connect server that is configured in staging mode. This server imports the same sync configuration but does not export changes to Azure AD. It can be used to preview changes, test configuration updates, and quickly take over if the primary server fails.
📈 Monitoring and Health
Use the Azure AD Connect Health portal to monitor sync health, view alerts, and gain insights into sync performance. It provides a dashboard for sync errors, authentication health (for PTA and AD FS), and performance metrics. Install the Health agents on your sync server and, if using AD FS, on your federation servers.
8.4 Single Sign‑On (SSO) – Seamless Authentication
🔑 What is Single Sign‑On?
Single Sign‑On (SSO) allows users to sign in once with a single set of credentials and access multiple applications without being prompted again. In a hybrid context, SSO means that when a user is signed into their domain‑joined computer, they are automatically signed into Azure AD and connected cloud applications without re‑entering their password.
🔄 How SSO Works in Hybrid Scenarios
Azure AD provides Seamless SSO (also called Seamless Single Sign‑On). When enabled, it automatically signs users in when they are on a corporate device connected to the corporate network. It works with both Password Hash Sync and Pass‑Through Authentication.
Technical Flow:
- User accesses a cloud application (e.g., outlook.office.com) from a domain‑joined device.
- Azure AD attempts to authenticate the user. It sends a challenge to the device asking for Kerberos authentication.
- The device, being domain‑joined, has a Kerberos ticket for the AZUREADSSO computer account (a special account created in on‑prem AD).
- The device responds with the Kerberos ticket, which is validated by Azure AD (via a connection to on‑prem DCs).
- If successful, the user is signed in without a password prompt.
This entire process is transparent to the user – they get a seamless experience.
⚙️ Enabling Seamless SSO
Seamless SSO is enabled during Azure AD Connect configuration (or can be enabled later). The steps:
- In Azure AD Connect, select the “Enable single sign‑on” option during custom installation.
- Azure AD Connect creates a computer account named
AZUREADSSOin the on‑premises AD domain (in the same container as domain controllers). This account represents Azure AD in the on‑prem environment. - The Kerberos decryption key for this account is securely shared with Azure AD.
- You must ensure that the
AZUREADSSOaccount’s password is managed – it should be updated regularly (Azure AD Connect can do this automatically). - On clients, the Intranet zone settings in Internet Explorer/Edge must include the Azure AD URLs (e.g., https://autologon.microsoftazuread-sso.com). This is usually done via Group Policy.
📋 Group Policy Settings for Seamless SSO
To ensure clients send Kerberos tickets to Azure AD, you need to add the following URLs to the Local Intranet zone:
https://autologon.microsoftazuread-sso.comhttps://aadg.windows.net.nsatc.net(for some Microsoft apps)
This is done via Group Policy: User Configuration → Preferences → Windows Settings → Registry or via Administrative Templates → Windows Components → Internet Explorer → Internet Control Panel → Security Page → Site to Zone Assignment List.
Additionally, ensure that the “Allow updates to status bar via script” setting is enabled.
🔐 Security Considerations
- The
AZUREADSSOcomputer account’s password should be rotated regularly (Azure AD Connect does this automatically every 30 days). - Seamless SSO only works for users who are in scope for synchronisation and have Kerberos tickets.
- It does not work for non‑domain‑joined devices (e.g., personal devices, mobile). Those users will be prompted for password (or use other methods like WHfB).
- If an attacker gains access to the
AZUREADSSOaccount, they could potentially impersonate users. Hence, protect it like a Tier 0 asset.
🌍 Other SSO Options
- Federation (AD FS): Provides SSO with more flexibility, such as support for smart cards and complex claims. Users authenticate to AD FS, which then issues SAML tokens for Azure AD.
- Third‑party IdP integration: Azure AD supports federation with non‑Microsoft identity providers (e.g., Okta, Ping) via SAML.
- Primary Refresh Token (PRT): On Windows 10/11 devices that are Azure AD joined or hybrid joined, a PRT is issued, enabling SSO across applications.
8.5 Designing a Hybrid Identity Architecture
🏗️ Introduction to Hybrid Identity Design
Designing a hybrid identity architecture involves making strategic decisions about how on‑premises AD and Azure AD will work together. The goal is to provide a seamless, secure, and manageable identity experience for users, whether they are accessing on‑premises resources or cloud applications. This section covers the key design considerations, scenarios, and best practices.
🎯 Key Design Decisions
When designing a hybrid identity solution, you need to answer several questions:
- Authentication method: Password hash sync, pass‑through authentication, or federation? (See comparison below.)
- User experience: Will you enable seamless SSO? Self‑service password reset with writeback?
- Device strategy: Will devices be Azure AD joined, hybrid joined, or both?
- Application requirements: Do you have on‑premises apps that need modern authentication? (Azure AD App Proxy may be needed.)
- Compliance and security: Are there regulations that restrict where password hashes can be stored?
- Identity governance: Will you use Azure AD PIM, access reviews, and entitlement management?
🔍 Comparison of Authentication Methods
| Method | Password Hash Sync (PHS) | Pass‑Through Auth (PTA) | Federation (AD FS) |
|---|---|---|---|
| How it works | Password hashes synchronised to Azure AD; Azure AD validates credentials. | Password validation happens on‑prem via an agent; no hash in cloud. | Authentication delegated to on‑prem AD FS; SAML tokens issued. |
| Complexity | Low – easy to set up and maintain. | Medium – requires agents, high availability. | High – requires AD FS farm, certificates, planning. |
| User experience | Good, especially with seamless SSO. | Good, especially with seamless SSO. | Excellent, supports rich claims and smart cards. |
| Security | Hashes in cloud (encrypted). Leaked credential detection available. | No hashes in cloud; on‑prem validation. | Full control over authentication; supports MFA on‑prem. |
| Hybrid features | Supports password writeback, leaked credential detection. | Supports password writeback (with PHS as fallback). | Supports all features, but writeback requires additional setup. |
| Best for | Most organisations; simple, secure, feature‑rich. | Organisations with strict “no hash in cloud” policies. | Organisations with existing AD FS; need for smart card or custom claims. |
🖥️ Device Identity Options
In a hybrid environment, you can register devices in Azure AD to enable conditional access based on device state. Two main options:
- Azure AD Join: Devices are joined directly to Azure AD, not to on‑prem AD. Suitable for cloud‑native organisations or devices that don't need on‑prem resources.
- Hybrid Azure AD Join: Devices are joined to on‑prem AD and also registered in Azure AD. This gives you single sign‑on to both on‑prem and cloud resources. It’s the most common choice for existing on‑prem environments.
Hybrid Azure AD Join requires Azure AD Connect to synchronise computer objects and a configuration that allows devices to auto‑register. This is typically done via Group Policy or an AD FS claim rule.
🔄 Synchronisation Scope and Filtering
You don’t have to synchronise all objects to Azure AD. Common filtering strategies:
- Sync all users and groups: Simplest, but may synchronise unnecessary objects.
- Sync only users with a license: Filter based on an attribute (e.g., extensionAttribute) that indicates cloud licensing.
- Sync only specific OUs: Exclude OUs containing service accounts or legacy users.
Use Azure AD Connect’s filtering options to implement these strategies. Remember that groups synchronised can contain members from filtered‑out OUs; careful planning is needed.
🏛️ Identity Governance and Security
Hybrid identity opens up advanced governance capabilities:
- Privileged Identity Management (PIM): Enable just‑in‑time access to Azure AD roles and Azure resources.
- Conditional Access: Create policies that require MFA, compliant devices, or trusted locations for access to cloud apps.
- Access Reviews: Periodically review group memberships and app assignments to ensure least privilege.
- Identity Protection: Detect and remediate risks like leaked credentials or anomalous sign‑ins.
📈 Sample Hybrid Architecture Scenarios
Scenario A: Small to Medium Business (SMB) – Simple and Cost‑Effective
- Single on‑prem AD forest.
- Azure AD Connect with Password Hash Sync and Seamless SSO.
- Azure AD Premium P1 licenses for Conditional Access and password writeback.
- Hybrid Azure AD Join for all workstations (via GPO).
- Intune for device management (optional).
Scenario B: Large Enterprise with Security Constraints – No Hashes in Cloud
- Azure AD Connect with Pass‑Through Authentication (with multiple agents for HA).
- Seamless SSO enabled.
- Password Hash Sync also enabled as a backup (if allowed).
- Federation (AD FS) may be used if existing, but PTA is simpler.
- Strict Conditional Access policies requiring MFA and compliant devices.
Scenario C: Highly Regulated with Smart Cards and Claims
- Azure AD Connect with federation to AD FS.
- AD FS farm with smart card authentication.
- Custom claims rules to pass on‑prem attributes to Azure AD.
- Azure AD Premium P2 for PIM and Identity Protection.
🔁 Migration Strategies – Moving from On‑Prem Only to Hybrid
A phased migration is recommended:
- Assessment: Inventory on‑prem AD, identify sync scope, choose authentication method.
- Pilot: Deploy Azure AD Connect in staging mode, test with a small set of users.
- Rollout: Enable sync for all users, configure seamless SSO and writeback.
- Device Registration: Implement Hybrid Azure AD Join via GPO.
- Conditional Access: Gradually introduce policies.
- Optimise: Enable PIM, access reviews, and identity protection.
📋 Best Practices Summary
- Always deploy at least two Azure AD Connect servers (primary + staging).
- Monitor sync health using Azure AD Connect Health.
- Keep the
AZUREADSSOaccount secure; let Azure AD Connect manage its password. - Use a dedicated service account for sync with minimal privileges.
- Test changes in staging mode before applying to production.
- Plan for disaster recovery – know how to force a sync server takeover.
- Regularly review sync errors and resolve them.
- Combine PHS with PTA for redundancy (if feasible).
- Educate users about self‑service password reset.
A well‑designed hybrid identity architecture provides the best of both worlds: the control and familiarity of on‑premises AD with the agility and innovation of the cloud. By carefully choosing authentication methods, device options, and governance features, you can create a secure and seamless experience for your users.
🎓 Module 08 : Hybrid AD & Azure Integration Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
Keep building your expertise step by step — Learn Next Module →
Module 09 : Advanced Active Directory Operations
This module provides a deep dive into the advanced internals and operational tasks that every senior Active Directory administrator must master. You will explore the AD database (NTDS.DIT) structure, tombstone lifecycle and Recycle Bin, offline maintenance with NTDSUtil, backup and disaster recovery strategies, authoritative vs non‑authoritative restores, schema management, time synchronization, upgrade paths, migration to new hardware or the cloud, and comprehensive health checks. These topics are essential for ensuring the long‑term health, performance, and recoverability of your Active Directory environment.
9.1 Active Directory Database (NTDS.DIT) Internals
🗄️ What is NTDS.DIT?
The NTDS.DIT (NT Directory Services Directory Information Tree) file is the heart of Active Directory. It is a database file that stores all directory data – users, groups, computers, passwords, and schema information. Every domain controller has its own copy of the NTDS.DIT for its domain, plus forest‑wide data (configuration and schema). The file is located in %SystemRoot%\NTDS\ by default.
Think of NTDS.DIT as a highly optimized, indexed database that holds every object and attribute in your domain. When you search for a user, the database engine retrieves it from this file.
⚙️ The Extensible Storage Engine (ESE)
NTDS.DIT is built on the Extensible Storage Engine (ESE) (also known as Jet Blue), the same database technology used in Exchange Server. ESE is an indexed, embedded database engine that provides high‑performance, transactional data storage. It uses a B‑tree (balanced tree) structure for indexes and stores data in 8 KB pages.
Key ESE concepts:
- Pages: The fundamental unit of storage (8 KB). Database contents are stored across many pages.
- Tables: Logical groupings of data. AD uses several tables:
datatable(object data),sd_table(security descriptors),link_table(linked attributes), etc. - Indexes: B‑tree structures that allow fast lookup by attribute (e.g., index on
objectGUID,cn). - Transaction logs: All changes are first written to a log file (
edb.log,edb00001.log, ...) before being committed to the database. This ensures consistency and enables recovery. - Checkpoint: A file (
edb.chk) that tracks which log entries have been written to the database.
📁 Database Structure
The NTDS.DIT file contains multiple internal tables:
- MSysObjects: System table tracking all tables and indexes.
- MSysLocales: Locale information.
- MSysDefrag: Used for online defragmentation.
- datatable: Stores most directory objects. Each row is an object, and columns represent attributes. Not all attributes are stored in the datatable – some are stored in separate tables (e.g., security descriptors).
- sd_table: Stores security descriptors (ACLs) for objects, de‑duplicated to save space.
- link_table: Stores linked attributes (e.g., group memberships, manager‑directReports).
Attributes themselves are stored using various data types: strings, integers, binary large objects (BLOBs), and multi‑valued attributes. The schema defines which attributes are present and their characteristics.
✍️ How Data is Written and Updated
ESE follows a write‑ahead logging protocol:
- A transaction begins (e.g., updating a user’s phone number).
- The changes are recorded in the transaction log file (
edb.log). - The log is forced to disk to ensure durability.
- The database is updated in memory and later (asynchronously) written to the main database file (
ntds.dit). - The checkpoint advances, indicating that all log entries up to a certain point have been flushed.
This design provides high performance (writes are sequential to logs) and ensures that even if the server crashes, logs can be replayed to bring the database to a consistent state.
🔄 Log File Management and Circular Logging
By default, AD uses circular logging. This means that after log files are no longer needed (their data has been checkpointed and they are not required for backup or recovery), they are overwritten. This keeps disk usage low but means you cannot perform point‑in‑time recovery from logs alone – you rely on backups.
If you need to support log shipping or advanced recovery, you can disable circular logging (not recommended for AD). The log files are located in the same folder as the database (%SystemRoot%\NTDS) and are named edb.log, edb00001.log, etc.
📏 Database Size and Growth
The size of NTDS.DIT depends on the number of objects, the number of attributes populated, and the size of security descriptors. A typical enterprise with 50,000 users might have a database size of 1‑2 GB. Very large environments (500,000+ objects) can see databases of 10‑20 GB or more. The database automatically grows as needed, but it never shrinks automatically. You must perform an offline defragmentation (see 9.3) to reclaim unused space.
🛡️ Database Security
The NTDS.DIT file is highly sensitive – it contains password hashes and other secrets. By default, only the SYSTEM account and administrators have access. It is encrypted with Boot Key (also stored in the registry) to protect against offline attacks. However, an attacker with physical access to the server could still potentially extract data. Hence, BitLocker and physical security are essential.
9.2 Tombstone Lifecycle & Active Directory Recycle Bin
⚰️ What are Tombstones?
When an object is deleted in Active Directory, it is not immediately removed from the database. Instead, it is converted into a tombstone – a special placeholder that retains a subset of the object’s attributes (e.g., objectGUID, objectSID, last known parent). This allows replication partners to learn about the deletion and propagate it, and also allows for authoritative restore scenarios. After a configurable period, the tombstone is permanently removed by the garbage collection process.
Think of a tombstone as a “deleted” marker on a file – it tells other systems that the object is gone, but the actual data isn't erased until the marker expires.
⏱️ Tombstone Lifetime (TSL)
The default tombstone lifetime is 180 days for domains created with Windows Server 2003 SP1 and later. This value determines how long a tombstone remains in the database before being permanently removed. It is critical for disaster recovery: if a domain controller is offline longer than the TSL, it will be out of sync and must be forcibly demoted.
You can view the tombstone lifetime in the configuration partition:
Get-ADObject -Identity "CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=contoso,DC=com" -Properties tombstoneLifetime
A value of 0 means the default (180 days) is used. You can adjust it (not recommended unless necessary) using ADSI Edit or PowerShell.
🗑️ How Tombstones Work
- User or administrator deletes an object (e.g., a user).
- The object’s
isDeletedattribute is set toTRUE. - Most attributes are stripped (only a few are retained:
objectGUID,objectSid,distinguishedName(with\0ADEL:prefix),lastKnownParent, etc.). - The tombstone is replicated to all other DCs, informing them of the deletion.
- After the tombstone lifetime expires, the garbage collection process removes the tombstone from the database.
♻️ Active Directory Recycle Bin
Introduced in Windows Server 2008 R2, the Active Directory Recycle Bin provides a way to restore deleted objects without restoring from backup. When enabled, deleted objects are preserved in a “deleted objects” container, and most attributes are retained, allowing a full restore.
How it works:
- When an object is deleted, it is moved to the “Deleted Objects” container (a special container visible when you enable “Advanced Features” in ADUC).
- The object retains nearly all its attributes (unlike a tombstone).
- The object enters a “deleted” state but can be restored with the
Restore-ADObjectPowerShell cmdlet or via ADAC. - After the tombstone lifetime, the object is transitioned to a “recycled” state and eventually removed.
Enabling the Recycle Bin:
# Enable the Recycle Bin (requires Schema Admin and Enterprise Admin)
Enable-ADOptionalFeature -Identity "CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=contoso,DC=com" -Scope ForestOrConfigurationSet -Target "contoso.com"
This change is irreversible. Once enabled, you cannot disable it. It raises the forest functional level to Windows Server 2008 R2 or higher.
Restoring a deleted object:
# Find deleted objects
Get-ADObject -Filter "Deleted -eq 'True' -and Name -eq 'jsmith'" -IncludeDeletedObjects
# Restore the object
Get-ADObject -Identity "CN=jsmith\0ADEL:abcdef12-3456-7890-abcd-ef1234567890,CN=Deleted Objects,DC=contoso,DC=com" -IncludeDeletedObjects | Restore-ADObject
📋 Best Practices
- Enable the Active Directory Recycle Bin on all forests – it's a lifesaver for accidental deletions.
- Never set tombstone lifetime lower than the longest expected offline period for a DC (e.g., if you have remote offices with poor connectivity, keep it at 180 days).
- Monitor for lingering objects (objects that have been deleted on one DC but not replicated due to offline DC) using
repadmin /removelingeringobjects.
9.3 Offline Maintenance: NTDSUtil & Database Defragmentation
🛠️ What is NTDSUtil?
NTDSUtil is a command‑line tool that provides management capabilities for Active Directory databases. It is the primary tool for offline maintenance tasks such as database defragmentation, integrity checks, moving database files, and authoritative restores. NTDSUtil must be run locally on a domain controller (or from an administrative workstation with RSAT, but offline operations require the DC to be stopped).
🧹 Offline Defragmentation (Compaction)
Over time, the AD database can become fragmented and contain unused space. This happens due to object deletions and modifications. An offline defrag (also called compaction) rebuilds the database file, reclaiming space and optimizing performance. It does not reorganize data for faster access – it simply creates a new, compacted database file.
Steps to perform offline defragmentation:
- Log on to the domain controller with administrative privileges.
- Open an elevated command prompt.
- Stop the Active Directory Domain Services:
net stop ntds(or use Services.msc). - Start NTDSUtil: type
ntdsutiland press Enter. - At the
ntdsutil:prompt, typeactivate instance ntds(if you have multiple instances; otherwise skip). - Type
filesto enter the file management menu. - Type
infoto see current database paths and sizes. - Type
compact to C:\temp\ntds(or any path with enough free space – at least 110% of current database size). This creates a compacted copy. - After compaction completes, type
quittwice to exit NTDSUtil. - Replace the original database file with the compacted one. The default paths are:
- Database:
C:\Windows\NTDS\ntds.dit - Logs:
C:\Windows\NTDS\(you may need to move logs separately, but usually you just replace the database).
copy C:\temp\ntds\ntds.dit C:\Windows\NTDS\ntds.dit. - Database:
- Restart AD DS:
net start ntds.
Note: After compaction, you may also need to move the log files if they were in a different location. Typically, the logs are left untouched.
🔍 Integrity Checks
NTDSUtil can also perform a semantic database analysis to check for corruption. This is useful after a suspected corruption or before a major upgrade.
# In NTDSUtil (after activating instance)
semantic database analysis
go
This runs a series of checks and reports any errors. It does not fix errors – it only reports them. To fix, you may need to restore from backup or perform an authoritative restore.
📂 Moving Database and Log Files
If you need to move the database or logs to another drive (e.g., for performance or space reasons), use NTDSUtil:
# At ntdsutil prompt
files
move db to D:\NTDS
move logs to E:\NTDSLogs
These commands require AD DS to be stopped.
🔄 Recovery Mode Operations
NTDSUtil is also used for authoritative restores (covered in 9.5) and for resetting the Directory Services Restore Mode (DSRM) password:
# Reset DSRM password
ntdsutil
set dsrm password
reset password on server null
📈 Best Practices for Offline Maintenance
- Perform offline defragmentation only when necessary (e.g., after large object deletions, before major upgrades).
- Always have a current backup before any offline maintenance.
- Plan maintenance during off‑peak hours.
- Consider performing online defragmentation (which runs continuously) as a background process – it reclaims space but does not compact the file.
- Monitor event logs for ESE errors (Event ID 474, 475, etc.) that indicate database problems.
9.4 Backup & Disaster Recovery Strategies
💾 Why AD Backup is Critical
Active Directory is the identity store for your entire organisation. If AD is lost, access to all resources is lost. A proper backup and disaster recovery (DR) strategy ensures that you can restore AD functionality in case of accidental deletion, corruption, hardware failure, or ransomware attack. AD backup is not optional – it is a fundamental requirement for business continuity.
🛡️ What to Back Up
- System State: On a domain controller, the system state includes the AD database (NTDS.DIT), SYSVOL, registry, boot files, COM+ class registration database, and other critical components. This is the minimum required to restore AD.
- Full Server Backup: Backing up the entire server (system state plus data drives) is recommended for bare‑metal recovery.
- Back up at least one DC per domain. Ideally, back up all DCs, but at minimum, ensure you have a recent backup of one DC per domain.
📦 Backup Tools
- Windows Server Backup (WSB): Built‑in feature that can back up system state and volumes. It supports scheduled backups to local disks, network shares, or removable media. It is free and simple, but has limitations (e.g., no cloud backup).
- Microsoft Azure Backup: Extends on‑premises backups to the cloud using the Microsoft Azure Recovery Services (MARS) agent. Supports system state backup for DCs.
- Third‑party tools: Veeam, Commvault, Backup Exec, etc., offer advanced features like application‑aware backups, granular restore, and offsite replication.
Using Windows Server Backup for System State:
# Install Windows Server Backup (if not already)
Install-WindowsFeature -Name Windows-Server-Backup
# Perform a one‑time system state backup to a network share
wbadmin start systemstatebackup -backupTarget:\\backupserver\share -quiet
🔄 Backup Frequency and Retention
- Frequency: At least daily backups. In dynamic environments, consider more frequent backups (e.g., every 6 hours).
- Retention: Keep at least 30 days of backups, or longer based on compliance requirements. Use grandfather‑father‑son retention policies.
- Offsite storage: Store copies offsite (e.g., in Azure, another datacenter) to protect against site‑wide disasters.
🧪 Testing Backups
A backup is only as good as its ability to be restored. Regularly test your backups by performing test restores in a lab environment. Verify that:
- You can restore system state to an alternate location.
- The restored AD is functional and can replicate.
- You can perform authoritative restores if needed.
🚨 Disaster Recovery Scenarios
- Single DC failure: If one DC fails, you can simply rebuild it (clean install, promote new DC). No restore needed if other DCs exist.
- All DCs in a domain lost: You must restore from backup (authoritative or non‑authoritative) on a DC, then bring up additional DCs via promotion.
- Accidental deletion of objects: Use the Recycle Bin (if enabled) or perform an authoritative restore.
- Database corruption: Restore from a known good backup.
- Ransomware attack: Isolate infected systems, restore from clean backups, and rebuild DCs.
📋 Best Practices Summary
- Back up at least one DC per domain daily.
- Store backups on a different server or in the cloud.
- Test restores quarterly.
- Document recovery procedures step by step.
- Include AD recovery in your overall disaster recovery plan.
- Consider using a dedicated backup service account with appropriate permissions.
9.5 Authoritative vs Non‑Authoritative Restore
🔄 Understanding Restore Types
When you restore Active Directory from backup, you have two choices: non‑authoritative (the default) or authoritative. The difference lies in how the restored data is treated during replication.
- Non‑authoritative restore: The restored DC receives updates from other DCs after restoration. Any changes that occurred after the backup will be replicated back to the restored DC, bringing it up to date. This is used when you are recovering a single DC that has failed, and other DCs are healthy.
- Authoritative restore: The restored data is marked as the authoritative version. When replication occurs, the restored data overwrites the data on other DCs. This is used to undo accidental deletions or changes (e.g., someone deleted a whole OU).
🛠️ Performing a Non‑Authoritative Restore
Non‑authoritative restore is the default restore mode. Steps (using Windows Server Backup):
- Boot the DC into Directory Services Restore Mode (DSRM). This is a special mode where AD is offline. You can enter DSRM by pressing F8 during boot or by configuring boot options.
- Log in with the DSRM local administrator account (password set during DC promotion).
- Open an elevated command prompt.
- Run
wbadmin get versionsto list available backups. - Restore system state:
wbadmin start systemstaterecovery -version:MM/DD/YYYY-HH:MM -backupTarget:\\server\share - After restore completes, reboot normally. The DC will start AD DS and replicate with other DCs to catch up.
🔁 Performing an Authoritative Restore
Authoritative restore requires using NTDSUtil after a non‑authoritative restore, to mark specific objects as authoritative.
- Follow steps 1‑5 above to perform a non‑authoritative restore of system state.
- After the restore, do not reboot (or reboot into DSRM again). You must be in DSRM.
- Run
ntdsutilat a command prompt. - Type
authoritative restoreto enter the authoritative restore menu. - To restore an entire subtree (e.g., an OU), use:
restore subtree "OU=Sales,DC=contoso,DC=com" - To restore a single object:
restore object "CN=John Smith,OU=Sales,DC=contoso,DC=com" - NTDSUtil will ask for confirmation and then update the object’s version number to be higher than on other DCs.
- Type
quittwice to exit. - Reboot normally. The restored objects will replicate to other DCs as authoritative.
Important: Authoritative restore increments the uSNChanged of the restored objects, making them newer than any existing copies. After replication, the authoritative objects overwrite others. Be careful – if you restore an entire domain, you can cause divergence.
🆚 When to Use Each
| Scenario | Restore Type |
|---|---|
| Single DC hardware failure (other DCs exist) | Non‑authoritative |
| All DCs lost; restoring a DC from backup | Non‑authoritative (if you have at least one other DC, but if all are lost, you may need authoritative to avoid conflicts) |
| Accidental deletion of a user/OU | Authoritative (or use Recycle Bin) |
| Accidental modification of many objects | Authoritative |
| Testing backups in a lab | Non‑authoritative (isolated environment) |
⚠️ Caveats and Considerations
- Authoritative restore increments update sequence numbers; if you restore a large subtree, replication traffic may spike.
- If you accidentally restore objects that were legitimately deleted, you may reintroduce them. Ensure you are certain about what you are restoring.
- The Recycle Bin is often a better choice for accidental deletions (it’s simpler and doesn’t require a restore from backup).
9.6 Managing Schema Extensions
📜 What is the Active Directory Schema?
The schema defines the structure of all objects and attributes in Active Directory. It is a forest‑wide database stored in the Schema partition. Every object class (e.g., user, group) and attribute (e.g., telephoneNumber) is defined in the schema. Applications like Exchange, Skype for Business, and third‑party software may extend the schema to add new classes or attributes they need.
🔧 Schema Master FSMO Role
Schema modifications can only be performed on the Schema Master (one per forest). This FSMO role holder is authoritative for all schema changes. To extend the schema, you must have Schema Admin privileges and be connected to the Schema Master.
➕ Extending the Schema
Schema extensions are typically performed using:
- LDIFDE: Import an LDIF file containing schema modifications. This is common for Exchange and other Microsoft products.
- Scripts (e.g., PowerShell with AD module): Using
Set-ADObjectto modify schema objects (advanced). - Built‑in installation programs: Many products include schema extension as part of their setup (e.g., Exchange prepares the schema automatically).
Example: Extending schema for Exchange 2019
Microsoft provides an LDIF file (SchemaUpdate.ldf) that must be imported using LDIFDE:
# Run on Schema Master with Schema Admin rights
ldifde -i -f SchemaUpdate.ldf -c DC=X DC=contoso,DC=com
The -c parameter replaces the placeholder DC with your actual domain distinguished name.
🛡️ Permissions Required
- Membership in the Schema Admins group (forest‑wide).
- Access to the Schema Master DC.
- Often Enterprise Admin rights may also be needed to modify certain schema objects.
📋 Best Practices for Schema Extensions
- Test first: Always test schema extensions in a lab environment that mirrors production.
- Document: Keep a record of all schema extensions, including when and why they were applied.
- Back up: Take a full system state backup of the Schema Master before extending.
- Plan maintenance windows: Schema changes replicate forest‑wide and may cause temporary performance impacts.
- Use the vendor’s recommended method: Follow instructions carefully; some extensions require specific preparation (e.g., raising functional levels).
- Limit Schema Admins: Keep the Schema Admins group empty except when performing extensions. Add members only temporarily.
🚫 Removing Schema Extensions
Schema extensions are permanent. Once a class or attribute is added, it cannot be removed (only deactivated). Deactivation makes it unavailable for new objects but does not remove existing data. To deactivate, you must use ADSI Edit to mark the attribute as defunct. This is risky and should only be done if absolutely necessary, and after consulting Microsoft support.
📊 Monitoring Schema Changes
Enable auditing for directory service changes. Look for Event ID 5136 (a directory service object was modified) on the Schema Master. Monitor for unexpected schema modifications, which could indicate compromise.
9.7 Time Synchronization (W32Time)
⏰ Why Time Sync Matters
Kerberos authentication relies on time stamps to prevent replay attacks. By default, Kerberos requires that client and server times be within 5 minutes of each other. If clocks drift beyond this, authentication fails. Therefore, accurate time synchronization across all domain members is critical.
📊 Time Hierarchy in Active Directory
Windows time synchronization follows a hierarchical model:
- Forest root PDC emulator: The authoritative time source for the entire forest. It should be configured to sync with an external reliable time source (e.g., a hardware clock, NIST, pool.ntp.org).
- Other domain controllers: Sync with the forest root PDC (or with other DCs in the same site).
- Domain members (servers and workstations): Sync with any DC in their domain (usually the one that authenticated them).
This hierarchy ensures that all systems have a consistent time.
⚙️ Configuring the PDC Emulator
To configure the PDC emulator to sync with an external NTP source:
# On the PDC emulator, run as administrator
w32tm /config /manualpeerlist:"0.pool.ntp.org 1.pool.ntp.org" /syncfromflags:manual /reliable:yes /update
net stop w32time && net start w32time
w32tm /resync
For higher accuracy, use more specific NTP servers (e.g., time.windows.com, time.nist.gov). You can also use Group Policy to configure time settings across all DCs.
🔍 Troubleshooting Time Sync
Common commands:
w32tm /query /status– Show current time source and offset.w32tm /query /peers– List configured NTP peers.w32tm /monitor– Check time against domain controllers.w32tm /resync– Force a resynchronization.
If you see errors, check that the time service is running, firewall ports (UDP 123 for NTP) are open, and the external source is reachable.
⚠️ Common Time Sync Issues
- Time drift on virtualised DCs: Virtual machines may drift due to host time changes. Disable time synchronization between the host and guest for DCs (let them sync from PDC).
- Firewall blocking NTP: Ensure UDP 123 is allowed outbound from the PDC.
- Misconfigured hierarchy: Some DCs might be pointed to external sources directly, breaking the hierarchy. Use Group Policy to enforce sync from the PDC.
📅 Group Policy for Time Sync
You can configure all client machines to use the domain hierarchy by default. No extra config is needed. However, you can enforce settings via Computer Configuration → Administrative Templates → System → Windows Time Service.
🔒 Security Considerations
- NTP is not authenticated by default. In high‑security environments, consider using authenticated NTP (with certificates) or use a hardware appliance.
- Prevent unauthorized time changes by restricting who can change system time (local policy).
9.8 Upgrading Active Directory (2008 → 2022)
📈 Why Upgrade?
Upgrading Active Directory brings new features, security improvements, and performance enhancements. It also ensures continued support from Microsoft. Common upgrade paths include moving from Windows Server 2008/2008 R2 to 2012/2012 R2, 2016, 2019, or 2022. This section covers the general process and considerations.
🗺️ Upgrade Approaches
- In‑place upgrade: Upgrade the operating system on existing domain controllers. This is possible but not recommended for DCs due to risk of issues. Use only for simple environments.
- Migration: Add new DCs running the new OS, transfer FSMO roles, then decommission old DCs. This is the preferred method – it’s safer and allows rollback.
📋 Pre‑upgrade Checklist
- Verify current forest and domain functional levels.
- Check hardware compatibility (64‑bit required, adequate RAM/disk).
- Ensure all DCs are healthy (
dcdiag /v,repadmin /replsummary). - Back up system state of all DCs.
- Review application compatibility (e.g., Exchange, SQL).
- Upgrade any prerequisite software (e.g., .NET Framework, PowerShell).
🔄 Migration Steps (Add new DCs, then decommission old)
- Prepare the new server: Install Windows Server (e.g., 2022) and join it to the domain.
- Install AD DS role: Promote the new server to a DC (adds it to the existing domain).
- Transfer FSMO roles: Move FSMO roles to the new DCs (optional, but recommended to have them on newer OS). Use
Move-ADDirectoryServerOperationMasterRole. - Move GC role: Ensure the new DC is a Global Catalog (if needed).
- Verify replication: Wait for replication to complete and verify with
repadmin /showrepl. - Decommission old DCs: Demote old DCs gracefully (
dcpromo /forceremovalif needed, but clean removal is better). - Raise functional levels: After all old DCs are removed, you can raise forest and domain functional levels to the new OS level (optional, required to enable new features).
📊 Functional Level Features
Raising the functional level enables new features:
- 2008 R2: Recycle Bin, DFSR for SYSVOL.
- 2012: Virtual DC cloning, Group Managed Service Accounts (gMSAs).
- 2012 R2: Improvements to DC cloning, Authentication Policies.
- 2016: Privileged Access Management (PAM), Azure AD Join support.
- 2019/2022: Further security enhancements, time service improvements.
🚨 Important Considerations
- Mixed environment: During migration, you will have DCs of different OS versions. This is supported but ensure all DCs are healthy.
- SYSVOL replication: If upgrading from 2008 (FRS) to a newer version, you must migrate SYSVOL from FRS to DFSR. This is a critical step; follow Microsoft guides carefully.
- Time sync: Ensure the PDC emulator (wherever it is) is configured correctly.
- PowerShell: Use
Get-ADDomainandGet-ADForestto check current levels.
🧪 Testing
Before production, test the entire migration in a lab that mirrors your environment. Validate that all applications work after the upgrade.
9.9 Migrating Active Directory to New Hardware / Cloud
🔄 Migration Scenarios
You may need to move AD to new hardware (e.g., server refresh) or to the cloud (Azure VMs). The approach is similar to upgrading: add new DCs, transfer roles, remove old ones. However, cloud migration adds considerations like network connectivity, latency, and hybrid configurations.
🏢 Migrating to New On‑Premises Hardware
This is straightforward: deploy new servers, promote them as DCs, transfer FSMO roles, and demote old servers. Follow the same steps as in 9.8. Ensure replication is healthy before decommissioning.
☁️ Migrating to Azure (IaaS)
Placing DCs in Azure can provide disaster recovery, offload authentication for hybrid users, and enable hybrid scenarios.
Steps:
- Plan networking: Ensure connectivity between on‑premises and Azure via VPN or ExpressRoute. DCs in Azure must be able to communicate with on‑prem DCs.
- Deploy Azure VMs: Create VMs with appropriate size (DS series recommended for DCs).
- Configure time sync: Disable host time sync for DC VMs (let them sync from on‑prem PDC).
- Promote to DCs: Join the domain and promote as additional DCs.
- Configure Sites and Services: Create a new site in AD Sites and Services representing the Azure region. Assign subnets to that site and create site links with appropriate costs.
- Move FSMO roles (optional): You may keep FSMO roles on‑prem or move to Azure.
- Decommission old hardware: Once Azure DCs are fully functional and replicating, demote old on‑prem DCs as needed.
📡 Important Azure Considerations
- Availability Sets / Availability Zones: Deploy at least two DCs in different fault domains for high availability.
- Disk performance: Use Premium SSDs for NTDS and logs to ensure adequate IOPS.
- Network Security Groups (NSGs): Restrict RDP and other management ports; allow AD traffic (TCP 135, 139, 445, 389, 636, 3268, 3269, etc.) only from trusted sources.
- Backup: Use Azure Backup to protect DC VMs.
- Do not run other workloads on DCs: Keep DCs dedicated to AD.
🔄 Hybrid Identity with Azure AD
When moving to Azure, you may also consider Azure AD Connect for hybrid identity. This is separate from IaaS DCs. IaaS DCs extend your on‑prem domain into Azure; Azure AD Connect synchronises to the cloud identity.
📉 Decommissioning Old Hardware
After all roles are transferred and replication is stable, gracefully demote old DCs. Use dcpromo /forceremoval only if the DC is unreachable. Then perform metadata cleanup if needed.
9.10 AD Health Checks (Best Practices Analyzer & Manual Checks)
🩺 Why Health Checks Matter
Regular health checks help you detect issues before they become critical. They ensure that replication is working, backups are valid, and the directory is free from errors. A proactive approach saves downtime and headaches.
🛠️ Built‑in Tools
- Best Practices Analyzer (BPA) for AD DS: Part of Server Manager, BPA scans domain controllers against Microsoft’s best practices and reports warnings, errors, and informational messages. It covers configuration, security, and performance.
- dcdiag: The domain controller diagnostics tool performs comprehensive tests (connectivity, replication, DNS, etc.). Run
dcdiag /v /con each DC. - repadmin: Use
repadmin /replsummaryto get a quick replication overview.repadmin /showreplshows detailed replication status. - Event Viewer: Check the Directory Service, DNS Server, and System logs for errors.
- PowerShell: Use cmdlets like
Test-ADDSDomainControllerInstallation,Get-ADReplicationFailure,Get-ADDomainControllerwith health checks.
📋 Manual Health Checklist
Perform these checks regularly (e.g., weekly) on each DC:
| Check | Command / Action | What to look for |
|---|---|---|
| Replication health | repadmin /replsummary |
No failures, all DCs listed, source/target errors zero. |
| Detailed replication | repadmin /showrepl * /csv > repl.csv |
All connections successful, no “last success” too old. |
| Time sync | w32tm /monitor |
All DCs within acceptable offset (less than 5 minutes). |
| DNS health | dcdiag /test:dns |
All tests passed, no missing SRV records. |
| Services status | Get-Service ntds, dns, w32time |
All running. |
| Disk space | Get-Volume |
Sufficient free space on NTDS and logs drives. |
| Event logs | Event Viewer (Directory Service, System, DNS) | No critical errors (especially Event ID 1925, 1988, 2042). |
| Backup validation | Check last backup time, test restore | Backup within acceptable window. |
| FSMO roles | Netdom query fsmo |
All roles present and on expected DCs. |
📊 Using Best Practices Analyzer
BPA can be run from Server Manager. Select “Active Directory Domain Services”, then click “Best Practices Analyzer” on the right. Review the results and address any errors. Common BPA warnings include:
- Time source not configured on PDC.
- SYSVOL replication not using DFSR.
- LDAP signing not enabled.
- DNS delegation issues.
🚨 Automated Health Monitoring
For large environments, automate health checks with scripts and integrate with a monitoring system (e.g., SCOM, Nagios, PRTG). Create scheduled tasks that run key commands and send alerts on failure.
# Example: PowerShell script to email replication failures
$repl = repadmin /replsummary
if ($repl -match "error") {
Send-MailMessage -To "admin@contoso.com" -Subject "AD Replication Errors" -Body $repl -SmtpServer smtp.contoso.com
}
📅 Recommended Frequency
- Daily: Automated alerts for critical failures (replication, services).
- Weekly: Run dcdiag and repadmin, review event logs.
- Monthly: Full BPA scan, review backup status.
- Quarterly: Test restore, review security settings.
Regular health checks are the key to a stable Active Directory. Make them part of your routine and respond to issues promptly.
🎓 Module 09 : Advanced AD Operations Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This concludes the Advanced Active Directory Operations module. You now have deep knowledge of AD internals, maintenance, recovery, and migration.
Module 10 : Advanced Group Policy & Fine‑Grained Password Policies
This module provides a comprehensive deep dive into advanced Group Policy management and Fine‑Grained Password Policies (FGPP). You will learn how to implement Password Settings Objects (PSOs) for granular password control, master GPO inheritance and enforcement, use WMI filtering for dynamic targeting, understand security filtering vs delegation, set up an ADMX Central Store, troubleshoot GPO issues, deploy advanced scripts, backup and migrate GPOs, secure GPOs from tampering, and differentiate between Group Policy Preferences and Policies. These advanced skills are essential for managing complex enterprise environments.
10.1 Fine‑Grained Password Policies (Password Settings Objects – PSO)
🔐 What are Fine‑Grained Password Policies?
In earlier versions of Windows Server (pre‑2008), only one password policy could exist per domain – the one defined in the Default Domain Policy. This was a significant limitation for organisations that needed different password requirements for different groups (e.g., stricter policies for administrators, more lenient for service accounts). Fine‑Grained Password Policies (FGPP), introduced in Windows Server 2008, allow you to create multiple password policies within a single domain and apply them to specific users or global security groups.
Think of FGPP as having different “password rules” for different teams – executives might need 15‑character passwords changed monthly, while a service account might have a 30‑character password that never expires.
📦 Password Settings Objects (PSOs)
A Password Settings Object (PSO) is a container that holds all the settings for a fine‑grained password policy. Each PSO contains:
- Precedence: A number that determines which PSO wins when multiple PSOs apply to a user. Lower numbers have higher priority.
- Password settings: Same as domain‑level policy – minimum length, complexity, history, age, etc.
- Lockout settings: Account lockout threshold, duration, and observation window.
- Applies to: Users or global security groups (cannot be applied directly to computer objects).
🛠️ Creating and Managing PSOs
PSOs are created in the Password Settings Container (CN=Password Settings Container,CN=System,DC=domain,DC=com). You can manage them using:
- Active Directory Administrative Center (ADAC): The easiest GUI method. Navigate to the domain → System → Password Settings Container, then use the “New” menu to create a PSO.
- PowerShell: The
New-ADFineGrainedPasswordPolicycmdlet.
PowerShell Example:
# Create a PSO for administrators
New-ADFineGrainedPasswordPolicy -Name "AdminsPSO" `
-Precedence 10 `
-MinPasswordLength 16 `
-ComplexityEnabled $true `
-LockoutThreshold 3 `
-LockoutDuration "00:30:00" `
-LockoutObservationWindow "00:30:00" `
-PasswordHistoryCount 24 `
-MaxPasswordAge "60.00:00:00" `
-MinPasswordAge "1.00:00:00"
# Apply the PSO to a group
Add-ADFineGrainedPasswordPolicySubject -Identity "AdminsPSO" -Subjects "Domain Admins"
📊 PSO Precedence and Evaluation
When a user belongs to multiple groups that have PSOs applied, the precedence value determines which PSO takes effect. The rule is: the PSO with the lowest precedence number wins. If a user has a PSO directly applied (not through a group), that PSO is considered first (and takes precedence over group‑based PSOs). The evaluation order is:
- PSOs directly applied to the user object.
- PSOs applied to global security groups the user is a member of (lowest precedence among those).
- If no PSO applies, the domain default password policy (from Default Domain Policy) is used.
You can view the resultant PSO for a user with:
Get-ADUserResultantPasswordPolicy -Identity jsmith
🔁 PSO Replication and Scope
PSOs are stored in the Configuration partition and replicate to all domain controllers in the forest. However, they apply only within the domain where they are created. If you have multiple domains, you need separate PSOs in each domain.
📋 Best Practices for PSOs
- Use groups (e.g., “AdminsPSO_Group”) to apply PSOs, not individual users, for easier management.
- Plan precedence numbers carefully – leave gaps (e.g., 10, 20, 30) to insert new policies later.
- Test PSOs on a pilot group before applying to critical groups.
- Document each PSO – its purpose, precedence, and target groups.
- Monitor for users who are not covered by any PSO – they will fall back to the domain policy.
- Never apply PSOs to protected users (Protected Users group) without testing, as their own protections may conflict.
10.2 GPO Inheritance, Blocking & Enforcing
🔄 The LSDOU Model Revisited
Group Policy processing follows the LSDOU order: Local, Site, Domain, and finally OU (with nested OUs processed from parent to child). By default, policies from higher levels are inherited by lower levels, and policies linked at lower levels (closer to the object) have higher precedence – they overwrite conflicting settings from higher levels. This default behaviour can be modified using Block Inheritance and Enforced (No Override).
🚫 Block Inheritance
Block Inheritance is a setting applied to a domain or an OU. When enabled, it prevents GPOs from higher‑level containers (site, domain, parent OUs) from being inherited by objects in that container. However, there is an exception: GPOs that are set to Enforced will still apply, even through a Block Inheritance setting.
How to enable Block Inheritance:
- In Group Policy Management Console (GPMC), right‑click the domain or OU → Block Inheritance.
- You'll see a blue exclamation mark on the container indicating block is enabled.
Use case: You have a divisional OU where you do not want any domain‑level policies to apply (e.g., a quarantine OU). You enable Block Inheritance, then link only the specific GPOs needed.
🔒 Enforced (No Override)
Enforced is a setting applied to a GPO link. When a GPO is enforced, its settings cannot be overridden by any GPO lower in the hierarchy, regardless of Block Inheritance or precedence. Enforced GPOs have the highest priority.
How to enforce a GPO:
- In GPMC, right‑click the GPO link → Enforced.
- You'll see a small lock icon on the link.
Use case: Security‑critical settings (e.g., password policy) are often enforced at the domain level to ensure they cannot be overridden by lower‑level GPOs.
⚖️ Interaction Between Block Inheritance and Enforced
The rules are simple:
- Enforced GPOs always apply (unless the GPO itself is disabled or security filtered out).
- Block Inheritance blocks non‑enforced GPOs from higher levels.
- Enforced GPOs from higher levels still apply even if Block Inheritance is enabled.
Example scenario:
- Domain GPO “Security Baseline” is enforced.
- OU “Finance” has Block Inheritance enabled.
- Result: The enforced “Security Baseline” GPO still applies to Finance objects. Any other domain‑level (non‑enforced) GPOs are blocked.
📊 Link Order and Precedence
When multiple GPOs are linked to the same container (e.g., an OU), the order of processing is determined by the link order. The GPO with the lowest link number is processed last and has the highest priority. You can change the link order in GPMC by selecting the container and using the up/down arrows on the linked GPOs list.
🧪 Practical Example: Designing GPO Inheritance
Consider a company with the following structure:
- Domain: contoso.com
- OU: Workstations (contains all workstations)
- OU: Workstations\Sales
- OU: Workstations\IT
GPOs:
- GPO1 (Domain): Corporate screensaver (enforced).
- GPO2 (Workstations OU): Basic security settings.
- GPO3 (Sales OU): Sales‑specific wallpaper.
- GPO4 (IT OU): IT‑specific PowerShell execution policy.
What happens?
- All workstations get the enforced corporate screensaver (GPO1).
- All workstations get basic security (GPO2).
- Sales workstations additionally get Sales wallpaper (GPO3).
- IT workstations get IT PowerShell policy (GPO4).
If the Sales OU had Block Inheritance enabled, GPO2 would not apply (unless enforced).
10.3 WMI Filtering for Dynamic Targeting
🔍 What is WMI Filtering?
Windows Management Instrumentation (WMI) filtering allows you to dynamically target GPOs based on attributes of the target computer, such as operating system version, hardware configuration, installed software, or network configuration. A WMI filter is a query that is evaluated on the target machine; if the query returns true, the GPO is applied. This enables precise, conditional application of Group Policy without creating multiple OUs.
WMI filters let you say “apply this GPO only to Windows 10 machines with at least 8 GB of RAM” – all from a single GPO.
🔧 Creating a WMI Filter
WMI filters are created in GPMC under the WMI Filters node. You write a WQL (WMI Query Language) query that returns a result set. If the result set is non‑empty, the filter evaluates to true.
Common examples:
# Apply to Windows 10 only
Select * from Win32_OperatingSystem where Version like "10.%"
# Apply to Windows Server 2019 or later
Select * from Win32_OperatingSystem where Version like "10.0.17763%" or Version like "10.0.20348%"
# Apply to laptops (chassis type = 8, 9, 10, 14)
Select * from Win32_SystemEnclosure where ChassisTypes = 8 or ChassisTypes = 9 or ChassisTypes = 10 or ChassisTypes = 14
# Apply to machines with more than 8 GB RAM
Select * from Win32_ComputerSystem where TotalPhysicalMemory > 8589934592
You can test WMI queries locally using PowerShell: Get-WmiObject -Query "Select * from Win32_OperatingSystem".
🔗 Linking a WMI Filter to a GPO
- In GPMC, select the GPO.
- In the right pane, click the Scope tab.
- Under WMI Filtering, select the desired filter from the dropdown.
- The GPO will now only apply to computers that satisfy the filter.
⚖️ Performance Considerations
- WMI filters are evaluated on the target machine during policy processing. A poorly written query can slow down policy application.
- Keep queries simple and avoid complex joins.
- Test queries thoroughly before deploying to production.
- WMI filters apply to computer policy only (they run in the computer context). They cannot be used for user policy targeting (you can use item‑level targeting in Preferences for that).
📋 Best Practices
- Use WMI filters sparingly – prefer OU structuring when possible, as it’s simpler and faster.
- Document each filter with its purpose and query.
- Use a naming convention (e.g., “Filter_Win10”, “Filter_8GB_RAM”).
- Be aware that WMI filters are not replicated across domains – they exist per domain.
🔁 Example: Deploying Software to Specific OS Versions
You have an application that only runs on Windows 10 21H2 and later. Instead of creating a separate OU for those machines, you create a WMI filter:
Select * from Win32_OperatingSystem where Version like "10.0.19044%" or Version like "10.0.19045%" or Version like "10.0.22000%"
Link this filter to the GPO that installs the software. Now, only eligible machines receive it.
10.4 Security Filtering vs Delegation
🔑 Understanding the Concepts
Two fundamental but often confused concepts in Group Policy are Security Filtering and Delegation. Both involve permissions, but they serve very different purposes.
- Security Filtering: Controls which users and computers receive and apply a GPO.
- Delegation: Controls who can manage the GPO (edit, delete, modify security).
🛡️ Security Filtering
By default, a new GPO is linked to the container where it's created, and its security filtering is set to “Authenticated Users” with Read and Apply Group Policy permissions. This means the GPO applies to all authenticated users and computers. To restrict the GPO to specific groups, you modify security filtering.
How it works:
- You grant a security group (e.g., “Sales Users”) the Read and Apply Group Policy permissions on the GPO.
- You remove “Authenticated Users” (or leave it, but then it still applies – so typically you remove it).
- Only members of that group will have the GPO applied.
Important: Security filtering works for both user and computer configurations. For computer configuration settings, the computer account must have Read and Apply permissions. So if you're filtering a computer configuration GPO to a specific computer group, ensure that group contains computer accounts.
Example: A GPO that deploys finance software should be filtered to the “Finance Computers” group.
👥 Delegation
Delegation controls administrative access to the GPO itself. In GPMC, you can delegate the following tasks:
- Edit settings
- Delete or modify security
- Link GPOs
- Read (view) settings
Delegation is configured on the Delegation tab of a GPO (or at domain level for linking rights). You add users or groups and assign the appropriate permissions. For example, you might delegate “Edit settings” to the “GPO Admins” group.
Common delegation scenarios:
- Helpdesk needs to link GPOs to specific OUs (delegate “Link GPOs” on the OU).
- A security team needs to edit security‑related GPOs (delegate “Edit settings” on those GPOs).
- Auditors need read‑only access to all GPOs (delegate “Read” on the domain’s GPOs).
🔍 Comparison Table
| Aspect | Security Filtering | Delegation |
|---|---|---|
| Purpose | Control which users/computers get the GPO | Control who can manage the GPO |
| Permissions used | Read + Apply Group Policy | Read, Write, Create, Delete, etc. |
| Target | Users, groups, computers | Administrators, groups |
| Where configured | GPO Scope tab → Security Filtering | GPO Delegation tab (or domain level) |
| Effect | GPO applies to filtered objects | Delegated users can perform administrative tasks |
⚠️ Common Mistakes
- Removing Authenticated Users from security filtering without adding another group – the GPO applies to no one.
- Adding users to security filtering with only Read permission (they need Apply Group Policy).
- Confusing delegation with security filtering – e.g., granting a user Edit permissions thinking that will make the GPO apply to them.
📋 Best Practices
- Use security groups for security filtering, not individual users.
- For computer settings, filter on computer groups.
- Document who has delegation rights on critical GPOs.
- Regularly review delegation to ensure least privilege.
10.5 ADMX Central Store
📂 What is the ADMX Central Store?
Administrative Template files (.ADMX) define the registry‑based policy settings available in Group Policy. Prior to Windows Vista/Server 2008, these files (.ADM) were stored locally on each administrative machine, leading to versioning conflicts and management headaches. The ADMX Central Store is a central repository in SYSVOL that stores all .ADMX and .ADML (language‑specific) files. When you edit a GPO from any machine with GPMC, it reads the templates from the Central Store, ensuring everyone uses the same set of policy definitions.
The Central Store is like a shared dictionary for Group Policy – every administrator reads from the same book, so they all speak the same language.
🛠️ Creating the Central Store
Creating the Central Store is simple – you create a folder in SYSVOL:
- On any domain controller, navigate to
\\contoso.com\SYSVOL\contoso.com\Policies. - Create a folder named PolicyDefinitions.
- Copy all .ADMX and .ADML files from a client or server’s
C:\Windows\PolicyDefinitionsfolder into this new folder. Include subfolders for each language (e.g.,en-US,de-DE).
After this, any administrator editing a GPO from any domain‑joined machine will automatically use the Central Store. The local PolicyDefinitions folder is no longer used (except as a fallback).
📥 Adding Custom or Third‑Party ADMX Files
Many applications (e.g., Office, Chrome, Adobe Reader) provide ADMX files for managing their settings via Group Policy. To make them available to all administrators:
- Download the ADMX files from the vendor.
- Copy the .ADMX files to the root of the Central Store (
PolicyDefinitions). - Copy the corresponding .ADML language files to the appropriate language subfolder (e.g.,
PolicyDefinitions\en-US). - Replication will distribute them to all DCs.
Now, when you edit a GPO, you'll see the new administrative template categories and settings.
🔄 Replication and Versioning
Because the Central Store is in SYSVOL, it replicates to all domain controllers. However, it does not automatically update when you install new Windows versions or service packs. You must manually copy new ADMX files when you introduce newer OS versions. For example, when you deploy Windows 11, copy its ADMX files to the Central Store to manage Windows 11‑specific policies.
📋 Best Practices
- Maintain a “master copy” of your Central Store on a file server or source control to track changes.
- Update the Central Store whenever you introduce a new OS version or application.
- Test new ADMX files in a lab before deploying to production.
- Use a naming convention for custom ADMX files to easily identify them.
- Document the version and source of each ADMX file.
10.6 GPO Logging & Troubleshooting
🔍 Why Troubleshoot GPOs?
Group Policy issues are among the most common problems in Active Directory – settings not applying, unexpected results, slow logons, or errors. Effective troubleshooting requires a systematic approach and knowledge of the right tools. This section covers the essential tools and techniques for diagnosing GPO problems.
🛠️ Essential Troubleshooting Tools
- gpresult: Shows the Resultant Set of Policy (RSoP) for a user or computer. Run
gpresult /rfor summary,gpresult /h report.htmlfor detailed HTML report. - rsop.msc: Graphical RSoP snap‑in (though deprecated, still useful for quick checks).
- Group Policy Results Wizard in GPMC: Simulates policy application for a target computer/user across the network.
- Group Policy Modeling Wizard in GPMC: Simulates “what if” scenarios (e.g., moving a computer to a different OU).
- Event Viewer: Look in Applications and Services Logs → Microsoft → Windows → Group Policy → Operational for detailed errors.
- PowerShell:
Get-GPOReport -Guidto export GPO details.-ReportType HTML -Path report.html - gpupdate: Force a remote group policy update with
Invoke-GPUpdate -Computer PC001 -RandomDelayInMinutes 0.
📋 Step‑by‑Step Troubleshooting Process
- Check the basics: Is the client connected to the domain? Can it reach a domain controller (DNS)? Run
nltest /dsgetdc:. - Run gpresult: On the affected machine, run
gpresult /r(orgpresult /scope:computerfor computer settings). Look for:- Which GPOs are listed as “Applied”.
- Any “Denied” GPOs and the reason (e.g., security filtering, WMI filter failed).
- The “Last time Group Policy was applied”.
- Check security filtering: Verify that the computer account (for computer policies) or user account (for user policies) has Read and Apply Group Policy permissions on the GPO. Also check if “Authenticated Users” was removed.
- Check WMI filters: If a WMI filter is attached, test it manually on the client:
Get-WmiObject -Query "your query". If it returns nothing, the filter fails. - Check inheritance: Is Block Inheritance enabled on the OU? Is the GPO enforced? These can override normal processing.
- Check GPO status: Is the GPO enabled (both computer and user sections can be disabled)? In GPMC, look for a red “X”.
- Check replication: If a GPO was recently modified, it may not have replicated to all DCs. Compare version numbers in GPMC (Domain and Sysvol columns). Use
repadmin /syncallto force replication. - Check Event Viewer: Look for GroupPolicy operational logs for errors (Event IDs 5000‑5999). Also check System and Application logs.
📊 Common GPO Errors and Fixes
| Error / Symptom | Possible Cause | Fix |
|---|---|---|
| GPO not applied (not listed in gpresult) | Security filtering missing, link disabled, OU inheritance blocked | Check permissions, enable link, check block inheritance |
| GPO listed as “Denied (Security)” | Authenticated Users removed, and current user/computer not in allowed group | Add appropriate group to security filtering |
| GPO listed as “Denied (WMI Filter)” | WMI filter evaluated to false | Check query, test on client |
| Settings not taking effect despite GPO applying | Conflicting GPO (higher precedence), local policy override, or setting not supported | Check link order, enforcement, use gpresult to see winning GPO |
| Slow logon / startup | Too many GPOs, large scripts, slow network, or software deployment | Consolidate GPOs, use asynchronous processing, move scripts to DFS |
| Event ID 1030: “The system cannot find the file specified” | Missing GPT folder in SYSVOL | Check SYSVOL replication, restore GPO from backup |
💻 Advanced Troubleshooting with PowerShell
# Get all GPOs that apply to a specific computer (simulate)
Get-GPResultantSetOfPolicy -ComputerName WS001 -ReportType Html -Path C:\rsop.html
# Get permissions for a GPO
Get-GPPermission -Guid "GPO-GUID" -All
# Force a remote group policy update
Invoke-GPUpdate -Computer WS001 -RandomDelayInMinutes 0
# Test a WMI filter remotely
Invoke-Command -ComputerName WS001 -ScriptBlock { Get-WmiObject -Query "Select * from Win32_OperatingSystem" }
10.7 Advanced Scripts via GPO
📜 Script Types in Group Policy
Group Policy can execute scripts at various points: computer startup/shutdown and user logon/logoff. These scripts can be batch (.bat), VBScript (.vbs), or PowerShell (.ps1). Advanced scripting allows you to perform complex configurations that go beyond built‑in policy settings.
🚀 PowerShell Scripts via GPO
PowerShell is the modern choice for scripting. To deploy PowerShell scripts via GPO:
- Place the script in a network share accessible by all target computers (e.g.,
\\contoso.com\SYSVOL\contoso.com\scripts\myscript.ps1). - In a GPO, navigate to Computer Configuration → Policies → Windows Settings → Scripts → Startup (or Shutdown, or User Configuration → Logon/Logoff).
- Double‑click the script type, click Add, browse to the script, and optionally add parameters.
- For PowerShell scripts, ensure the execution policy allows them. You can set the policy via GPO: Computer Configuration → Policies → Administrative Templates → Windows Components → Windows PowerShell → Turn on Script Execution.
⚙️ Advanced Script Examples
Example 1: Map network drives based on group membership
# Logon script (PowerShell)
$salesDrive = "\\fileserver\sales"
$itDrive = "\\fileserver\it"
# Remove existing mapped drives (optional)
Get-SmbMapping | Where-Object { $_.LocalPath -eq "S:" } | Remove-SmbMapping -Force -UpdateProfile
# Map based on group membership
if ( (Get-ADGroupMember -Identity "Sales Team" -Recursive | Select-Object -ExpandProperty SamAccountName) -contains $env:USERNAME ) {
New-SmbMapping -LocalPath "S:" -RemotePath $salesDrive -Persist $true
} elseif ( (Get-ADGroupMember -Identity "IT Team" -Recursive | Select-Object -ExpandProperty SamAccountName) -contains $env:USERNAME ) {
New-SmbMapping -LocalPath "I:" -RemotePath $itDrive -Persist $true
}
Example 2: Install software if not present (startup script)
# Computer startup script (PowerShell)
$softwareName = "7-Zip"
$installerPath = "\\fileserver\software\7z1900-x64.msi"
if (-not (Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*$softwareName*" })) {
msiexec /i $installerPath /quiet /norestart
}
🔄 Script Ordering and Timing
- Startup scripts: Run in the system context, before the user logs on. They have access to the entire machine but not user profiles.
- Logon scripts: Run in the user context, after the user logs on but before the desktop appears (synchronous by default).
- Shutdown/Logoff scripts: Run when the system shuts down or user logs off, with limited time to complete.
You can configure script timeout and whether to run them synchronously or asynchronously via GPO settings under Administrative Templates → System → Scripts.
🔐 Security Considerations for Scripts
- Store scripts on a secure, highly available network share. Use DFS for redundancy.
- Ensure the share permissions allow “Read” for Domain Computers (for startup scripts) and Domain Users (for logon scripts).
- Sign your PowerShell scripts with a trusted certificate to prevent tampering and set execution policy to “RemoteSigned”.
- Log script execution – include logging in your scripts and collect logs centrally.
- Avoid storing credentials in scripts. Use Group Managed Service Accounts (gMSAs) or other secure methods.
📊 Comparing Scripts to Preferences
Group Policy Preferences (e.g., drive maps, registry settings) are easier to configure and manage than scripts. However, scripts offer unlimited flexibility and logic (if/then, loops, external calls). Use preferences for simple, declarative tasks; use scripts for complex conditional logic.
10.8 GPO Backup, Restore & Migration
💾 Why Backup GPOs?
Group Policy Objects are critical configuration assets. Accidental deletion, misconfiguration, or corruption can affect thousands of users. Regular backups of GPOs allow you to restore to a known good state. Backups are also essential when migrating GPOs between domains (e.g., from test to production) or forests.
🛠️ Backing Up GPOs
Using GPMC:
- Open GPMC, right‑click Group Policy Objects (or a specific GPO).
- Select Back Up All (or Back Up for a single GPO).
- Choose a location (e.g., a network share) and optionally provide a description.
- GPMC creates a folder with a timestamp and saves each GPO as a set of files (including the GPT and GPC information).
Using PowerShell:
# Backup all GPOs to a folder
Backup-GPO -All -Path "\\backupserver\GPOBackups" -Comment "Monthly backup $(Get-Date)"
# Backup a single GPO
Backup-GPO -Name "Default Domain Policy" -Path "\\backupserver\GPOBackups"
🔄 Restoring GPOs
Using GPMC:
- In GPMC, right‑click Group Policy Objects → Manage Backups.
- Browse to the backup location, select the GPO and backup version.
- Click Restore. This overwrites the existing GPO (if present).
Using PowerShell:
# Restore a GPO from backup Restore-GPO -Name "Sales GPO" -Path "\\backupserver\GPOBackups" -BackupId
Restoring a GPO does not affect its links. If you restore to a different domain (migration), you will need to handle security principals (see below).
🌉 Migrating GPOs Between Domains
Migrating GPOs from one domain to another (e.g., test to production) requires careful handling of security principals (users, groups) that may differ between domains. GPMC provides a Migration Table to map source principals to destination principals.
Migration steps:
- Back up the GPO in the source domain.
- Copy the backup folder to a location accessible from the destination domain.
- In the destination domain, open GPMC, right‑click Group Policy Objects → Open Migration Table Editor.
- Create a migration table that maps source domain users/groups to destination equivalents (e.g., CONTOSO\SalesGroup to FABRIKAM\SalesGroup).
- Right‑click Group Policy Objects → Import Settings. Point to the backup, choose to import, and apply the migration table.
- The GPO is created in the destination domain with translated security principals.
Using PowerShell for migration:
# Import a GPO with a migration table Import-GPO -BackupId-Path "\\backupserver\GPOBackups" -TargetName "Sales GPO" -MigrationTable "\\server\migrationtable.migtable"
📋 Best Practices
- Schedule regular GPO backups (e.g., weekly).
- Store backups in a secure, off‑site location.
- Include GPO backups in your overall disaster recovery plan.
- Test restoration in a lab periodically.
- Use migration tables when moving GPOs between domains to avoid broken permissions.
- Document the purpose of each GPO in the backup description.
10.9 GPO Security: Preventing Tampering
🛡️ The Importance of GPO Security
GPOs contain critical security settings, software deployment configurations, and scripts. If an attacker (or a disgruntled administrator) can modify GPOs, they can compromise the entire domain – for example, by adding a malicious script to a startup GPO. Protecting GPOs from unauthorised changes is therefore paramount.
🔒 Default GPO Permissions
By default, the following groups have permissions on GPOs:
- Domain Admins: Full control.
- Enterprise Admins: Full control.
- SYSTEM: Full control.
- Authenticated Users: Read access (required for GPOs to be applied).
- Domain Computers: Read access (for computer policies).
Additional groups (e.g., “GPO Admins”) may be delegated edit rights.
📋 Hardening GPO Permissions
- Restrict who can create GPOs: By default, any domain user can create GPOs. Change this via GPMC: right‑click Group Policy Objects → Delegate → remove “Authenticated Users” from “Create GPOs” and add only specific groups.
- Limit edit permissions: Only grant “Edit settings” to users/groups that absolutely need it. Use groups, not individual users.
- Protect the “Default Domain Policy” and “Default Domain Controllers Policy”: These are critical. Consider removing edit rights from all except Domain Admins.
- Use Protected Groups: Ensure that members of groups like “GPO Admins” are also in Protected Users and use PAWs.
- Audit changes: Enable auditing on the GPO containers (in AD) to track modifications (see below).
🔍 Auditing GPO Changes
To detect tampering, you must audit changes to GPOs. This involves two parts: auditing changes to the GPO container in AD, and auditing changes to the GPT files in SYSVOL.
Audit AD changes (GPC):
- Enable advanced auditing on domain controllers for “Directory Service Changes”.
- Monitor Event ID 5136 (a directory service object was modified), 5137 (created), 5141 (deleted). Filter for objects in the
CN=Policies,CN=System,DC=...container.
Audit SYSVOL changes (GPT):
- Enable auditing on the SYSVOL share and folder using File Server Resource Manager or advanced audit policies (Object Access).
- Monitor Event ID 4663 (an attempt was made to access an object) for the
\Policiesfolder.
Using PowerShell to get GPO version history:
# Get GPO version (user and computer) – changes when GPO is edited
Get-GPO -Name "Sales GPO" | Select-Object DisplayName, ModificationTime, UserVersion, ComputerVersion
🔁 Protecting Against Ransomware
Ransomware often targets GPOs to disable defences or deploy ransomware via startup scripts. To mitigate:
- Implement the “Golden Image” approach – store a read‑only copy of critical GPOs.
- Use a separate administrative forest (bastion forest) for managing GPOs in production (privileged access workstation model).
- Regularly back up GPOs and store backups offline.
- Monitor for unexpected GPO changes and alert immediately.
📋 Best Practices Summary
- Delegate GPO management to the smallest possible group.
- Use security groups for delegation, not individual users.
- Restrict GPO creation to authorised administrators.
- Enable auditing on GPO containers and SYSVOL.
- Regularly review delegated permissions.
- Consider using Microsoft’s “Protected Users” and PAWs for GPO administrators.
10.10 Group Policy Preferences vs Policies
🔄 Understanding the Difference
Group Policy has two main types of settings: Policies and Preferences. They behave differently and serve different purposes.
- Policies: Enforced settings that cannot be changed by the user. They are applied and re‑applied every 90‑120 minutes (background refresh). If a user changes a policy‑controlled setting, it will be reverted at the next refresh. Policies are stored in the Registry.pol file.
- Preferences: Configurable settings that are applied once and then can be changed by the user. Preferences are not enforced – if a user modifies a preference setting, it stays changed. Preferences are stored in the registry under normal user keys and can be targeted via item‑level targeting.
📁 Where to Find Them
In the Group Policy Editor, both appear under the same nodes (e.g., “Administrative Templates” are policies, while “Preferences” are a separate folder under both Computer and User Configuration).
- Policies: Under Computer Configuration → Policies → Administrative Templates and similar for User Configuration.
- Preferences: Under Computer Configuration → Preferences and User Configuration → Preferences. Inside, you'll find subfolders for Windows Settings (e.g., Drive Maps, Environment, Files, Folders, Ini Files, Registry, Shortcuts) and Control Panel Settings.
🎯 Item‑Level Targeting in Preferences
One of the most powerful features of Preferences is item‑level targeting. You can configure a preference item (e.g., a drive map) to apply only when certain conditions are met, such as:
- User is a member of a specific group.
- Computer is in a specific IP range.
- Operating system version matches a pattern.
- Specific environment variable is set.
- Time of day.
This is configured by clicking the “Targeting” button in the properties of a preference item. You can combine multiple conditions with AND/OR logic.
🔍 Comparison Table
| Aspect | Policies | Preferences |
|---|---|---|
| Enforcement | Enforced – cannot be changed by user | Not enforced – user can change |
| Refresh | Re‑applied every 90‑120 minutes | Applied once (by default) and not re‑applied unless forced |
| Storage | Registry.pol (protected) | Normal registry keys (HKCU, HKLM) |
| Targeting | Limited to OU, security filtering, WMI | Rich item‑level targeting (group, IP, OS, etc.) |
| Typical use | Security settings, mandatory configurations | User environment settings (drives, printers), optional configurations |
📋 When to Use Each
- Use Policies for:
- Security settings (password policy, user rights, firewall rules).
- Settings that must be enforced and cannot be changed by users.
- Settings that need to be re‑applied regularly (e.g., to fix user changes).
- Use Preferences for:
- User convenience settings (drive maps, printer connections).
- Settings that may need to differ based on dynamic conditions (item‑level targeting).
- One‑time configurations (e.g., initial registry settings that users can later customise).
⚠️ Security Consideration for Preferences
Preferences store some sensitive data (like local user passwords for scheduled tasks) in the GPT (SYSVOL). These are encrypted but the key is publicly known. Therefore, never store passwords in Preferences – use Group Policy Policies or other secure methods instead.
🔄 Converting Preferences to Policies
There is no direct conversion. If you need to enforce a setting that is currently a preference, you must find the equivalent policy setting (if it exists) and configure it separately. Some settings are only available as preferences.
🎓 Module 10 : Advanced GPO & FGPP Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This concludes the Advanced Group Policy and Fine‑Grained Password Policies module. You now have expert-level knowledge to manage, secure, and troubleshoot Group Policy in complex enterprise environments.
Module 11 : Active Directory Sites, Replication & Networking
This module provides a comprehensive deep dive into Active Directory site topology, replication, and networking. You will learn how to design and configure sites and subnets, manage site links and costs, understand bridgehead servers and intersite replication protocols, monitor replication health with repadmin, resolve conflicts and USN rollback, secure AD communication through firewalls, optimize replication for large enterprises, and deploy Read‑Only Domain Controllers (RODCs) in branch offices. Mastering these concepts is essential for ensuring efficient, resilient, and secure Active Directory operations in distributed environments.
11.1 Site Topology & Subnet Configuration
🌐 What are Active Directory Sites?
An Active Directory site is a logical representation of a physical location with good network connectivity – typically a LAN. Sites are used to manage replication traffic and direct clients to the nearest domain controllers. The site topology is defined in the Active Directory Sites and Services console (or PowerShell) and consists of sites, subnets, and site links.
Think of sites as “locations” on a map. If you have offices in New York, London, and Tokyo, you create a site for each. Subnets tell AD which IP ranges belong to which site.
🗂️ Why Sites Matter
- Client affinity: Domain‑joined computers find a domain controller in their own site first, reducing authentication latency and WAN traffic.
- Replication control: Intra‑site replication (within a site) is frequent and uncompressed; inter‑site replication (between sites) can be scheduled and compressed to conserve bandwidth.
- Service location: Services like DFS, Exchange, and others use site information to optimize traffic.
🔧 Defining Subnets
A subnet in AD is an IP address range (e.g., 192.168.10.0/24) associated with a site. When a client’s IP falls within a subnet, the client is assigned to that site. Subnets are created in the Sites and Services console under the “Subnets” folder.
PowerShell example to create a subnet and associate it with a site:
New-ADReplicationSubnet -Name "192.168.10.0/24" -Site "NewYork"
🏢 Creating and Managing Sites
By default, a new forest has one site (Default‑First‑Site‑Name) and one subnet. You should rename this to reflect your actual location and add more sites as needed.
Steps to create a site:
- Open Active Directory Sites and Services.
- Right‑click “Sites” → New Site.
- Enter a site name (e.g., “London”) and select a site link (initially, use DEFAULTIPSITELINK).
- Click OK. The site is created with no domain controllers yet.
- Add subnets to the site.
- Move or add domain controllers to the site by dragging the server object into the site’s Servers container.
PowerShell equivalent:
New-ADReplicationSite -Name "London"
Set-ADReplicationSiteLink -Identity "DEFAULTIPSITELINK" -SitesIncluded @{Add="London"}
📋 Site Naming Conventions
Use consistent, descriptive names: “Site-City” or “Site-Region”. Avoid special characters. Document your site topology with a diagram.
🌍 How Clients Find Their Site
When a domain‑joined computer starts, it queries DNS for SRV records and also performs a site lookup. The NetLogon service on the client sends a DSGetSiteName request to a domain controller, which returns the site name based on the client’s IP subnet. The client then caches this site information.
⚙️ Site Coverage and Automatic Site Assignment
If a client’s IP does not match any defined subnet, it is assigned to the site that contains the domain controller it first contacted (or the site of that DC). This can lead to suboptimal performance. Always define all subnets to ensure correct assignment.
📊 Best Practices for Site and Subnet Design
- Create a site for every physical location with a dedicated WAN link.
- Define all subnets used in your organisation, including VPN pools.
- Use a consistent naming scheme and document everything.
- Review and update subnets when network changes occur.
- Consider using DHCP scope options to help clients locate DCs (though site‑awareness is primary).
11.2 Site Links & Cost Metrics
🔗 What are Site Links?
Site links connect two or more sites and define the replication path between them. They are logical connections that the Knowledge Consistency Checker (KCC) uses to build the replication topology. Each site link has properties: cost, replication interval, and schedule.
💰 Cost
Cost is an arbitrary value (default 100) that represents the “expense” of using that link. Lower costs are preferred. The KCC uses costs to determine the least‑cost path for replication between sites. For example, if you have a high‑bandwidth link between New York and London, set a low cost (e.g., 10); for a slow satellite link, set a high cost (e.g., 200). Costs are relative – you can use any values as long as they reflect the actual network speed and reliability.
The KCC builds a spanning tree based on cumulative costs. If multiple site links connect the same sites, the KCC may use both for redundancy, but the lowest cost path is preferred.
⏱️ Replication Interval
The replication interval (default 180 minutes) determines how often replication occurs over the site link. You can set it from 15 minutes to 10,080 minutes (7 days). Shorter intervals reduce latency but increase bandwidth usage. For high‑capacity links, use 15‑30 minutes; for slow links, use longer intervals (e.g., 4‑6 hours). The interval is a baseline – urgent replication (see 11.5) can bypass it.
📅 Schedule
The schedule defines when replication is allowed. By default, it is always available. You can restrict replication to off‑peak hours (e.g., only between 10 PM and 6 AM) to conserve bandwidth during business hours. However, urgent replication (password changes, lockouts) will still occur if the schedule is set to “Replicate during the indicated time slots”. The schedule is a 7‑day grid with 15‑minute increments.
🔀 Site Link Types
- IP link: Uses RPC over IP for replication. This is the standard.
- SMTP link: Deprecated, uses SMTP for replication (only for configuration and schema partitions, not domain). Not recommended.
🛠️ Creating and Configuring Site Links
Using GUI (Sites and Services):
- Expand “Inter‑Site Transports” → right‑click “IP” → New Site Link.
- Enter a name (e.g., “NY‑London‑Link”).
- Select two or more sites to connect.
- Set cost, interval, and schedule.
PowerShell example:
New-ADReplicationSiteLink -Name "NY-London-Link" -SitesIncluded "NewYork","London" -Cost 50 -ReplicationFrequencyInMinutes 30
Set-ADReplicationSiteLink -Identity "NY-London-Link" -Schedule "0000.1111111.0000000..." # complex hex string
📊 Site Link Bridges
By default, all site links are considered “bridged” – meaning they are transitive. If you have Site A linked to Site B and Site B linked to Site C, the KCC can replicate from A to C via B. This is usually desired. You can disable automatic bridging and create manual site link bridges if you need to control the topology more strictly (rare).
📈 Cost Calculation Examples
- Scenario 1: NY to London (cost 10), London to Tokyo (cost 20). The cumulative cost from NY to Tokyo via London is 30. If a direct NY‑Tokyo link exists with cost 40, the KCC will prefer the 30 path.
- Scenario 2: You have redundant links between two sites: a fast link (cost 10) and a backup slow link (cost 100). The KCC will use the fast link primarily, but if it fails, replication will still occur over the slow link (if the KCC creates a connection).
11.3 Bridgehead Servers & Intersite Replication
🌉 What is a Bridgehead Server?
A bridgehead server is a domain controller in a site that is responsible for sending and receiving replication data to/from other sites. The KCC automatically selects one or more bridgehead servers per site, per directory partition, per transport (IP). This design reduces the replication load: only the bridgehead communicates with remote sites; other DCs in the site replicate from the bridgehead.
🔄 How Bridgehead Servers Are Selected
The KCC on the Inter‑Site Topology Generator (ISTG) – a role held by one DC in each site – selects bridgehead servers based on:
- Availability: DCs that are online and reachable.
- Global Catalog status: For global catalog partitions, the bridgehead must be a GC.
- Preference: You can designate a preferred bridgehead server by setting the “Preferred Bridgehead” attribute on a server object. If a preferred bridgehead is set, the KCC will use it if available (but may also select others for load balancing).
🛠️ Configuring Preferred Bridgehead Servers
To set a preferred bridgehead server:
- In Active Directory Sites and Services, expand the site, then expand Servers.
- Right‑click the server → Properties.
- In the “Transport” list, select “IP” and click “Add”. The server is now a preferred bridgehead for IP replication.
Caution: If you set a preferred bridgehead and it fails, the KCC may not automatically fail over (it can, but it might take time). It's often better to let the KCC manage selection automatically.
📦 Intersite Replication Process
- The bridgehead server in Site A checks for changes in its directory partitions.
- At the scheduled interval (site link frequency), it contacts the bridgehead in Site B and requests changes.
- Data is compressed (by default) to save bandwidth.
- The bridgehead in Site B then replicates changes to other DCs in its site via intra‑site replication.
🔄 Bridgehead Failover
If a bridgehead server fails, the KCC (specifically the ISTG) detects the failure (by monitoring connection objects) and promotes another DC in the site to serve as bridgehead. This may take up to 15 minutes (the KCC run interval). To speed recovery, you can have multiple preferred bridgeheads or let the KCC manage.
📊 Multiple Bridgeheads and Load Balancing
In large sites, the KCC may select multiple bridgeheads to distribute the replication load. For example, different directory partitions (domain, configuration, schema) might be handled by different bridgeheads. This is automatic and transparent.
🔍 Monitoring Bridgehead Status
Use repadmin /bridgeheads to list bridgehead servers per site:
repadmin /bridgeheads
This shows which DCs are acting as bridgeheads and for which partitions.
11.4 Replication Protocols (RPC, SMTP)
📡 RPC over IP – The Default Protocol
Active Directory replication uses Remote Procedure Call (RPC) over TCP/IP as the default transport. RPC is efficient, secure, and supports both intra‑site and inter‑site replication. For intra‑site replication, RPC is used without compression (fast). For inter‑site replication, RPC can compress data to reduce bandwidth usage (enabled by default). RPC uses a dynamic port range (49152‑65535) by default, but you can restrict it to a specific port (e.g., 5000) for firewall purposes (see 11.8).
📦 RPC Replication Characteristics
- Intra‑site: Notify‑push model; changes are sent immediately to replication partners (by default within 15 seconds).
- Inter‑site: Scheduled pull model; bridgeheads request changes from other sites based on site link schedule.
- Compression: Inter‑site data is compressed (configurable) to reduce bandwidth.
- Authentication: RPC replication uses Kerberos or NTLM for secure communication.
📧 SMTP – The Legacy Alternative
SMTP replication was introduced for environments where RPC over IP was not feasible (e.g., across unreliable or high‑latency links). It uses SMTP (email) as the transport. However, SMTP replication has significant limitations:
- It can only replicate the configuration, schema, and application partitions – not domain data (no users, groups, etc.).
- Requires a certification authority (CA) to issue certificates for signing and encryption.
- Complex to set up and maintain.
- Deprecated in newer Windows Server versions; not recommended for any modern deployment.
In practice, SMTP replication is rarely used. If you have connectivity challenges, consider using RPC over IP with scheduled replication or deploying RODCs.
🔁 Choosing the Right Protocol
For all practical purposes, use RPC over IP. It is reliable, secure, and well‑supported. If you need to replicate across a firewall, you can configure a static port for RPC (see 11.8) to simplify firewall rules.
🛡️ Securing RPC Replication
- Enable Kerberos authentication (default).
- Use IPsec to encrypt replication traffic if required (though RPC signing offers some protection).
- Restrict RPC ports via firewall to only allow replication between DCs.
- Enable LDAP signing and channel binding on DCs.
11.5 Urgent Replication & Change Notification
⏱️ What is Urgent Replication?
Certain changes in Active Directory are considered urgent and must replicate immediately to all domain controllers, even across site links, to prevent security issues or service disruption. Urgent replication bypasses the normal site link schedule and interval.
🔔 Changes that Trigger Urgent Replication
- Account lockouts: When a user is locked out, this change replicates urgently to prevent the user from authenticating elsewhere.
- Password changes: When a user changes their password, the new password hash replicates urgently to the PDC emulator first, and then to other DCs (but the urgent flag applies to the PDC sync).
- RID pool updates: When a DC requests a new RID pool from the RID master, this is urgent.
- LSA secrets changes: Changes to trusted domain objects (inter‑domain trust passwords).
- Changes to the domain controller’s computer account password? (machine account password changes are not urgent but handled by regular replication).
🔄 How Urgent Replication Works
When a DC makes a change that is marked urgent, it notifies its replication partners immediately (within 15 seconds for intra‑site). For inter‑site replication, the change is sent to the bridgehead server in the site, which then notifies the bridgehead in other sites, and replication occurs immediately, regardless of the site link schedule. However, the inter‑site transport still honours the “replication available” schedule – if the site link schedule disallows replication at that time, urgent replication will not occur. Therefore, it’s important to have site links available 24/7 or at least allow urgent replication windows.
📋 Configuring Urgent Replication
Urgent replication is built‑in and not directly configurable. However, you can influence it by setting the site link schedule. For example, if you block replication overnight, urgent changes will queue until the schedule permits. To ensure urgent changes always replicate, keep the schedule open.
⚙️ Change Notification within a Site
Within a site, DCs notify each other of changes by default. This is controlled by the Change Notification setting. You can disable change notification for a connection (making it “pull only”) but that is rarely done.
📊 Example Scenario
A user in New York is locked out after 5 bad password attempts. The authenticating DC (in New York) immediately replicates the lockout to all other DCs in the same site. It also notifies the bridgehead, which sends the change to the bridgehead in London (ignoring the 180‑minute interval) because the change is urgent. Within minutes, the user is locked out everywhere.
11.6 Monitoring Replication with Repadmin
🔍 Introduction to Repadmin
Repadmin (Replication Administrator) is the command‑line tool for diagnosing and managing Active Directory replication. It is part of the Remote Server Administration Tools (RSAT) and is essential for any AD administrator. Repadmin can display replication status, force replication, check for errors, and much more.
🛠️ Essential Repadmin Commands
| Command | Description | Example |
|---|---|---|
repadmin /replsummary |
Summarises replication status across all DCs – shows source/target errors and latest success times. | repadmin /replsummary |
repadmin /showrepl |
Displays detailed replication status per DC, including inbound connections and last success/failure. | repadmin /showrepl DC01.contoso.com |
repadmin /syncall |
Forces replication of a DC with all its partners. | repadmin /syncall /e /A /P /d /q |
repadmin /queue |
Shows pending replication operations (outbound). | repadmin /queue DC01 |
repadmin /failcache |
Displays recent replication failures. | repadmin /failcache * |
repadmin /bridgeheads |
Lists bridgehead servers per site. | repadmin /bridgeheads |
repadmin /kcc |
Forces the KCC to recalculate the replication topology. | repadmin /kcc DC01 |
repadmin /removelingeringobjects |
Removes lingering objects from a DC (use with caution). | repadmin /removelingeringobjects DC01 dc=contoso,dc=com /advisory_mode |
📊 Using Repadmin for Health Checks
A typical health check workflow:
- Run
repadmin /replsummary– look for any DCs with errors in the “Source” or “Destination” columns. A healthy forest shows all zeros. - If errors exist, run
repadmin /showrepl DCnameto see detailed failures. Look for “last success” time and error messages. - Run
repadmin /failcache *to see a history of failures. - If you find consistent failures, check network connectivity, firewall, and DNS.
- After fixing, run
repadmin /syncall /e /A /P /d /qto force replication and verify.
📈 Interpreting Repadmin Output
In repadmin /showrepl, you’ll see entries like:
DC=contoso,CN=Configuration,DC=contoso,DC=com
Default-First-Site-Name\DC01 via RPC
DC object GUID:
Address: 00000000-0000-0000-0000-000000000000._msdcs.contoso.com
DSA Options: IS_GC
DSA invocationID:
USNs: 123456 / OU, 123456 / OU
Last attempt @ 2023-10-01 12:34:56 was successful.
...
Key fields:
- Last attempt: Time of last replication.
- Last success / last failure: Indicators of health.
- USNs: Update Sequence Numbers – show which changes have been replicated.
🔁 Scheduling Repadmin Checks
Automate replication monitoring with scripts. For example, run repadmin /replsummary daily and email results. Use PowerShell to parse output and alert on errors.
/syncall during peak hours.
11.7 Conflict Resolution & USN Rollback
🔄 How Replication Conflicts Are Resolved
Active Directory is a multi‑master system, meaning changes can occur on any DC at any time. When conflicting changes happen (e.g., an attribute is modified on two DCs simultaneously), AD uses a conflict resolution algorithm based on:
- Version number: Each attribute has a version number (starting at 1) that increments with each change. Higher version wins.
- Timestamp: If versions are equal, the later timestamp (according to the originating DC’s clock) wins.
- Buffer: If timestamps are equal (rare), the DC with the lower GUID wins.
The losing change is either discarded or stored as a “link value” in a conflict object (visible in the “LostAndFound” container).
🆔 Update Sequence Numbers (USNs)
Each DC maintains a local USN (Update Sequence Number) for every object and attribute. When a change occurs, the USN increments. Replication partners track which USNs they have received using High Watermark and UpToDateness Vector. This ensures that each change is replicated exactly once.
⚠️ USN Rollback – A Critical Failure
USN rollback occurs when a DC is restored from an old backup without proper procedures, causing its USN to go backwards (i.e., it thinks it has seen fewer changes than it actually has). When this DC replicates, it may reintroduce old data, causing conflicts and potential corruption. This is a severe issue that can destabilise the entire forest.
How USN rollback happens:
- A DC fails and is restored from a backup that is older than the tombstone lifetime.
- The restored DC has USNs that are lower than the current USNs on other DCs.
- When it replicates, it claims to have “missed” changes, and other DCs send it updates. However, the restored DC may also have changes that are newer than those on other DCs (if it had changes before the backup), leading to conflicts.
Symptoms of USN rollback:
- Event ID 2042 – “It has been too long since this machine replicated…” (indicating the DC is too far behind).
- Event ID 1988 – “The local domain controller has attempted to replicate an object that does not exist on the source.” (lingering objects).
- Replication failures and inconsistencies.
🛠️ Resolving USN Rollback
If you suspect USN rollback:
- Immediately isolate the affected DC from the network (disable network adapters).
- Do not attempt to replicate.
- Force demote the DC (using
dcpromo /forceremovalorRemove-ADDomainController) and clean up metadata. - Promote a new DC from a healthy backup or fresh install.
In some cases, you can use repadmin /removelingeringobjects to remove objects that were incorrectly introduced, but this is risky and should only be attempted with Microsoft support.
📋 Preventing USN Rollback
- Never restore a DC from a backup older than the tombstone lifetime (default 180 days).
- Always use the Directory Services Restore Mode (DSRM) and authoritative/non‑authoritative restore procedures correctly.
- Regularly monitor replication health and event logs.
- If you need to rebuild a DC, always promote a new one rather than restoring from backup.
11.8 AD over Firewalls – Port Requirements
🔥 Firewall Considerations for Active Directory
When domain controllers are separated by firewalls (e.g., between sites or in a DMZ), you must open specific ports to allow replication, authentication, and other AD services. The following table lists the essential ports and protocols.
📊 Required Ports for AD DS
| Protocol / Port | Purpose | Direction |
|---|---|---|
| TCP 88 | Kerberos authentication | Bidirectional |
| UDP 88 | Kerberos authentication (sometimes) | Bidirectional |
| TCP 135 | RPC Endpoint Mapper | Bidirectional |
| TCP 139 | NetBIOS Session (legacy) | Bidirectional (optional) |
| UDP 137-138 | NetBIOS (legacy) | Bidirectional (optional) |
| TCP 445 | SMB (File Replication – SYSVOL, etc.) | Bidirectional |
| TCP 389 | LDAP (plain) | Bidirectional |
| UDP 389 | LDAP (for UDP, rarely used) | Bidirectional |
| TCP 636 | LDAPS (LDAP over SSL) | Bidirectional |
| TCP 3268 | Global Catalog (plain) | Bidirectional |
| TCP 3269 | Global Catalog (SSL) | Bidirectional |
| TCP 49152-65535 | Dynamic RPC ports (for replication, etc.) | Bidirectional |
| TCP 5722 | RPC for File Replication (DFSR) | Bidirectional |
| UDP 123 | NTP (time sync) | Bidirectional |
| TCP 9389 | AD Web Services (PowerShell) | Bidirectional |
Note: The dynamic RPC port range (49152‑65535) can be restricted to a smaller range or a specific port by modifying the registry on DCs. This is often done to simplify firewall rules.
🔧 Restricting RPC Dynamic Ports
To restrict RPC to a specific port (e.g., 5000‑5100), you can configure the registry on each DC:
reg add HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Parameters /v "TCP/IP Port" /t REG_DWORD /d 5000 /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Parameters /v "TCP/IP Port Range" /t REG_SZ /d "5000-5100" /f
After setting, restart the NetLogon service. Then you can open only that range in the firewall.
📡 DFSR Ports
If you use DFSR for SYSVOL replication (recommended), it also uses RPC dynamic ports. You can restrict DFSR ports similarly.
🛡️ Security Best Practices for Firewalls
- Use the principle of least privilege – only open necessary ports between specific DCs, not entire subnets.
- Use IPsec to encrypt traffic if traversing untrusted networks.
- Consider using a dedicated management VLAN for replication traffic.
- Monitor firewall logs for unusual access attempts.
- If using VPNs between sites, ensure they are stable and low‑latency.
11.9 Optimizing Replication for Large Enterprises
📈 Challenges in Large Environments
In large enterprises with hundreds of domain controllers and thousands of sites, replication can become a bottleneck. Optimisation involves balancing timely replication with bandwidth constraints. Key strategies include:
🗺️ Site Link Design
- Create a hub‑and‑spoke topology: place hub sites with high‑bandwidth links to spokes. Use appropriate costs to ensure replication flows through the hub.
- Avoid creating a mesh of site links – it increases complexity and may cause the KCC to generate too many connections.
- Use multiple site links for redundancy with different costs.
⏱️ Replication Schedule and Interval
- Set longer intervals (e.g., 180‑360 minutes) for low‑bandwidth links. Adjust based on business needs.
- Use schedules to restrict replication to off‑peak hours, but ensure urgent changes still propagate (if schedule is open).
- Consider using “replication availability” schedules to block replication during peak business hours for non‑urgent data.
⚙️ Bridgehead Server Optimisation
- Ensure bridgehead servers are powerful enough to handle intersite replication load.
- If you have multiple DCs in a hub site, let the KCC select multiple bridgeheads to load‑balance.
- Monitor bridgehead CPU and network usage; upgrade if necessary.
🗜️ Compression
Intersite replication compresses data by default. This reduces bandwidth but increases CPU usage on bridgeheads. If you have very high bandwidth (e.g., 1 Gbps) and low latency, you can disable compression to reduce CPU overhead. This is set on the site link:
Set-ADReplicationSiteLink -Identity "NY-London-Link" -ReplicationSchedule $null -Replace @{options=1} # options=1 disables compression
Options: 0 = compress, 1 = no compression, 2 = ignore schedule (always replicate). Be careful: disabling compression may flood links.
🔄 Global Catalog Optimisation
Global Catalog servers replicate all objects in the forest (partial). In very large forests, GC replication can be heavy. Consider:
- Limiting GCs to major sites only.
- Using universal group caching (enabled on a site) to allow sites without GCs to authenticate, reducing GC replication traffic.
🔁 Universal Group Caching
Universal group caching allows a site without a GC to cache universal group memberships. When a user logs on, the DC retrieves universal group memberships from a GC and caches them for a period (default 8 hours). This reduces the need for a GC at every site. Enable it in the site properties:
Set-ADReplicationSite -Identity "London" -UniversalGroupCachingEnabled $true
📊 Monitoring and Tuning
Regularly use repadmin /showrepl to check replication latency. If latency exceeds acceptable limits, consider adding site links, increasing bandwidth, or adjusting schedules.
11.10 Read‑Only Domain Controller (RODC) in Branch Offices
🏢 What is an RODC?
A Read‑Only Domain Controller (RODC) is a type of domain controller that hosts a read‑only copy of the Active Directory database. It was introduced in Windows Server 2008 to address security concerns in branch offices with limited physical security. RODCs are ideal for locations where you cannot guarantee the safety of the server.
🔐 Key Features of RODC
- Read‑only database: No direct writes; all changes must replicate from a writable DC.
- Credential caching: By default, RODCs do not cache user passwords. You can configure a Password Replication Policy (PRP) to cache passwords for specific users (e.g., branch office employees) to allow local authentication. Administrative accounts are never cached.
- Administrator role separation: A local user (e.g., branch office manager) can be delegated administrative rights on the RODC (e.g., to update drivers) without any domain privileges.
- Replication filtering: You can filter which attributes replicate to the RODC, reducing replication traffic and exposure of sensitive data.
🛠️ Deploying an RODC
Before deploying an RODC, the forest functional level must be at least Windows Server 2003. The process is similar to promoting a writable DC, but with the “Read‑only domain controller” option selected.
Prerequisites:
- A writable DC must be available in the domain.
- You should pre‑stage the RODC computer account (recommended).
- Define the Password Replication Policy.
PowerShell example to promote an RODC:
Install-ADDSDomainController -ReadOnlyReplica -DomainName "contoso.com" -SiteName "BranchSite" -AllowPasswordReplicationAccountName "BRANCH\AllowedUsers" -Credential (Get-Credential)
🔑 Password Replication Policy (PRP)
The PRP controls which user and computer accounts can have their passwords cached on the RODC. It consists of two lists:
- Allowed list: Accounts whose passwords may be cached. Typically includes users and computers in the branch office.
- Denied list: Accounts that must never be cached. By default, administrative groups (Domain Admins, Enterprise Admins, etc.) are denied.
When a user authenticates to an RODC and their password is not cached, the RODC forwards the request to a writable DC (over the WAN). After successful authentication, the RODC may cache the password (if allowed) for future use.
To manage PRP via PowerShell:
Add-ADDomainControllerPasswordReplicationPolicy -Identity "RODC01" -AllowedList "BRANCH\SalesUsers"
🌐 RODC and Sites
RODCs are placed in sites like any other DC. Clients in the branch site will discover the RODC and use it for authentication. If the password is not cached, the RODC will refer the client to a writable DC (which may be in another site), causing a WAN authentication. To avoid this, ensure that all branch users are in the allowed PRP.
🔒 Security Advantages of RODC
- If an RODC is stolen, only the cached passwords (of allowed accounts) are compromised, not the entire domain’s credentials.
- The read‑only nature prevents attackers from modifying AD from that server.
- Separation of administrative roles reduces risk.
📋 Best Practices for RODC
- Only cache passwords for necessary users; keep the allowed list minimal.
- Use the default denied list (administrators) – never cache privileged accounts.
- Place RODCs in physically unsecured locations.
- Monitor PRP and authentication logs for unusual activity.
- Ensure the RODC has a reliable connection to a writable DC for replication and password forwarding.
🎓 Module 11 : Sites, Replication & Networking Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
You now have expert-level knowledge of Active Directory site topology, replication, and networking – essential for managing distributed enterprise environments.
Module 12 : Active Directory Security – Threats & Advanced Hardening
This module provides a comprehensive deep dive into Active Directory security, covering both the offensive techniques used by attackers and the defensive measures to protect your environment. You will learn how to map attack paths with BloodHound, understand Kerberoasting, AS‑REP Roasting, Golden/Silver/Diamond tickets, DCSync, ACL abuse, and ADCS attack vectors. You will also master defensive controls such as SMB/LDAP signing, LAPS, Credential Guard, Protected Users, advanced auditing, Microsoft Defender for Identity, and incident response. This module equips you with the knowledge to both assess and harden your AD environment against the most sophisticated threats.
12.1 Attack Path Mapping with BloodHound
🕵️ What is BloodHound?
BloodHound is an open‑source tool that uses graph theory to reveal hidden and often unintended relationships in Active Directory environments. It helps attackers (and defenders) find complex attack paths that could lead to domain compromise. BloodHound consists of:
- SharpHound: A data collector that runs on a domain‑joined machine to gather information about users, groups, computers, sessions, ACLs, and trust relationships.
- BloodHound GUI: A Neo4j database‑powered interface that visualises the data and allows querying for attack paths.
🔍 How Attackers Use BloodHound
Attackers typically:
- Gain a foothold on a low‑privileged user or workstation.
- Run SharpHound (often in‑memory to avoid detection) to collect AD data.
- Import the data into BloodHound and use pre‑built queries to find:
- Shortest paths to Domain Admin.
- Users with administrative sessions on high‑value servers.
- Kerberoastable accounts.
- ACL abuse opportunities (e.g., GenericAll on a privileged group).
- Unconstrained delegation endpoints.
- Follow the identified path to escalate privileges and move laterally.
🛡️ Defenders Using BloodHound
Defenders should run BloodHound regularly (e.g., monthly) and review the findings:
- Find and fix high‑risk paths: Look for “Domain Admin” reachable within a few hops. Investigate why a standard user can reach a domain admin via a series of group memberships or session data.
- Identify over‑privileged accounts: Users with excessive rights, especially those with “GenericAll” or “WriteOwner” on sensitive objects.
- Detect Kerberoastable accounts with weak passwords: BloodHound lists all accounts with SPNs; use this to audit service account passwords.
- Monitor for changes: Compare BloodHound runs over time to see if new risky paths appear.
⚙️ Running BloodHound
Collector (SharpHound):
# Run as a domain user (no special privileges needed)
SharpHound.exe --CollectionMethods All --Domain contoso.com --OutputPrefix "audit"
Import and Analyse:
- Start Neo4j database (included with BloodHound).
- Launch BloodHound GUI, connect to Neo4j.
- Upload the collected ZIP file.
- Use built‑in queries (e.g., “Find all Domain Admins”, “Shortest Paths to Domain Admins”, “Users with most privileges”).
📊 Key BloodHound Queries for Defenders
- Find all users with SPNs (potential Kerberoasting): `MATCH (u:User {hasspn:true}) RETURN u`
- Find computers with unconstrained delegation: `MATCH (c:Computer {unconstraineddelegation:true}) RETURN c`
- Find principals with DCSync rights: `MATCH p=(u)-[:AllowedToReplicate]->(d:Domain) RETURN p`
- Find users with administrative sessions on high‑value servers: `MATCH (c:Computer)-[:HasSession]->(u:User) RETURN c.name, u.name`
🔐 Remediating BloodHound Findings
When you find a risky path, take action:
- Remove unnecessary group memberships.
- Enforce least privilege – break nested group chains.
- Restrict who can log on to sensitive servers.
- Set strong passwords for service accounts or use gMSAs.
- Disable unconstrained delegation.
12.2 Kerberoasting & AS‑REP Roasting
🔑 Kerberoasting – Attacking Service Accounts
Kerberoasting is an attack that targets service accounts. Any domain user can request a Service Ticket (ST) for any service account that has a Service Principal Name (SPN) registered. The ST is encrypted with the service account's NTLM hash. The attacker extracts the encrypted portion and offline‑cracks it to recover the plaintext password.
How Kerberoasting Works:
- SPN Discovery: The attacker enumerates accounts with SPNs (e.g., using
Get-ADUser -Filter {ServicePrincipalName -ne "$null"}). - Ticket Request: The attacker requests a Service Ticket for a target service account (e.g., for the SPN
MSSQLSvc/sqlserver.contoso.com) using any valid domain user account (even a low‑privileged one). - Ticket Extraction: The attacker receives an ST encrypted with the service account's NTLM hash. Tools like Rubeus or Mimikatz extract the encrypted part.
- Offline Cracking: The attacker cracks the hash offline using Hashcat or John the Ripper. Weak passwords are cracked quickly.
Impact: If the service account is over‑privileged (e.g., Domain Admin), the attacker gains high privileges. Even if not, they can use the account for lateral movement.
🌙 AS‑REP Roasting
AS‑REP Roasting targets user accounts that have the Kerberos pre‑authentication requirement disabled. When pre‑auth is disabled, the KDC will send an AS‑REP (containing encrypted data) without first verifying the user's timestamp. An attacker can request this AS‑REP for any such user and offline crack the encrypted portion.
How AS‑REP Roasting Works:
- Find vulnerable accounts: The attacker enumerates users with the
DONT_REQ_PREAUTHflag set (userAccountControl attribute). - Request AS‑REP: The attacker sends an AS‑REQ for one of these users without pre‑authentication data. The KDC responds with an AS‑REP that includes encrypted data (the session key encrypted with the user's password hash).
- Extract and crack: The attacker extracts the encrypted part and cracks it offline.
🛡️ Mitigations for Kerberoasting
- Use Group Managed Service Accounts (gMSAs): gMSAs have complex, 120‑character random passwords that change automatically every 30 days, making cracking infeasible.
- Strong passwords for service accounts: If you must use standard user accounts as service accounts, ensure they have extremely strong, randomly generated passwords (20+ characters) and change them frequently.
- Enable AES encryption: Kerberoasting often targets RC4‑encrypted tickets because they are easier to crack. Disable RC4 and require AES for Kerberos (via Group Policy). This forces attackers to crack AES hashes, which are more difficult.
- Monitor for unusual service ticket requests: Look for Event ID 4769 where the ticket encryption type is 0x17 (RC4) if you have disabled RC4. Also monitor for many 4769 events from the same user for different SPNs.
- Limit SPN registration: Only allow authorised users to register SPNs.
🛡️ Mitigations for AS‑REP Roasting
- Ensure all user accounts require pre‑authentication: This is the default in modern AD. Periodically audit for accounts that have pre‑auth disabled. Use PowerShell:
Get-ADUser -Filter {userAccountControl -band 4194304}. - Use strong passwords: Even with pre‑auth disabled, a strong password makes cracking infeasible.
- Monitor for AS‑REP requests: Look for Event ID 4768 (TGT requested) where pre‑authentication was not required (failure code 0x6).
12.3 Golden, Silver & Diamond Tickets
👑 Golden Ticket Attack
A Golden Ticket is a forged TGT (Ticket Granting Ticket) that allows an attacker to impersonate any user (including non‑existent ones) with any group memberships (like Domain Admins). It is forged using the KRBTGT account's password hash.
How it works:
- Attacker compromises a domain controller or extracts the KRBTGT hash from a DC's LSASS (or NTDS.dit).
- Using Mimikatz (
kerberos::golden), they forge a TGT for any user, specifying the domain SID, user RID (e.g., 500 for built‑in admin), and group RIDs (e.g., 512 for Domain Admins). - The forged TGT is injected into memory. The attacker can now request Service Tickets for any resource.
Why it's dangerous:
- The forged TGT is indistinguishable from a real one (signed with the real KRBTGT key).
- It can have an arbitrarily long lifetime (years).
- Even if the original compromise is cleaned, the Golden Ticket remains valid until the KRBTGT password is changed twice.
🔗 Silver Ticket Attack
A Silver Ticket is a forged Service Ticket (ST) for a specific service. It is forged using the service account's NTLM hash. Unlike a Golden Ticket, it does not require contact with the KDC.
How it works:
- Attacker obtains the hash of a service account (e.g., a computer account, or a user with an SPN).
- Using Mimikatz, they forge an ST for that specific service (e.g., CIFS on a file server).
- The forged ST is presented directly to the service, granting access.
Why it's stealthy: No KDC contact means no Event ID 4769 on domain controllers. The only logs are on the target service.
💎 Diamond Ticket Attack
A Diamond Ticket is a variation that involves modifying an existing legitimate TGT (obtained via a user's credentials) by decrypting it, modifying its fields (e.g., adding group memberships), and re‑encrypting it with the KRBTGT hash. It is less common but can evade some detection mechanisms.
🛡️ Mitigations for Ticket Attacks
- Protect domain controllers: They are Tier 0 assets. Use PAWs, strict access controls, and monitoring to prevent KRBTGT hash theft.
- Regularly rotate the KRBTGT password: Change it twice (with a delay) every 180 days or after any suspected compromise. This invalidates existing Golden Tickets.
- Enable Kerberos armoring (FAST): Protects the TGS exchange, making it harder to use forged tickets.
- Monitor for anomalous ticket usage:
- Event ID 4768: Look for TGT requests with unusually long lifetimes (>10 hours).
- Event ID 4769: Look for service ticket requests from unusual accounts or for sensitive services.
- Event ID 4624: Logons with unusual privileges.
- Use Managed Service Accounts: For service accounts, use gMSAs which have automatic password rotation, limiting Silver Ticket windows.
12.4 DCSync & DCShadow Attacks
🔄 DCSync Attack
DCSync is a technique that abuses the Directory Replication Service (DRS) Remote protocol (MS‑DRS). An attacker with appropriate privileges (by default, Domain Admins, Enterprise Admins, and Domain Controllers) can impersonate a domain controller and request replication of sensitive data, including password hashes for all users.
How DCSync Works:
- Attacker gains credentials with replication rights (often via Golden Ticket or compromised Domain Admin).
- Using Mimikatz (
lsadump::dcsync) or Impacket's secretsdump, the attacker requests replication of user objects from a target DC. - The DC, believing the request comes from an authorised partner, sends back the requested data, which includes password hashes (NTLM, LM if enabled) and Kerberos keys.
Impact: The attacker obtains hashes for all users, including the KRBTGT account, enabling Golden Ticket attacks and offline cracking.
🕵️ DCShadow Attack
DCShadow is a more advanced attack where an attacker registers a rogue domain controller and uses it to push malicious changes to AD (e.g., adding a user to Domain Admins) without leaving normal audit logs. It requires high privileges (Domain Admin) and coordination between two machines.
How DCShadow Works:
- Attacker with Domain Admin rights runs a server that impersonates a DC.
- They use tools (like Mimikatz's
lsadump::dcshadow) to replicate a malicious change (e.g., add a user to a privileged group). - The change is pushed to other DCs via replication, appearing as a legitimate replication event.
- Because the change originates from a “DC”, it may bypass certain auditing that focuses on interactive changes.
🛡️ Mitigations
- Restrict replication permissions: By default, only Domain Controllers, Enterprise Admins, and Domain Admins have replication rights. Audit these groups regularly. Consider creating a dedicated security group for replication and removing these rights from built‑in groups (advanced).
- Enable advanced auditing for replication:
- Monitor Event ID 4662 – “An operation was performed on an object.” Look for events where the object type is the Domain‑DNS object and the access mask includes
Control Access(right 100) for the control access rightDS-Replication-Get-Changes(GUID:1131f6aa-9c07-11d1-f79f-00c04fc2dcd2). - Alert on any 4662 event with these attributes originating from an IP that is not a known domain controller.
- Monitor Event ID 4662 – “An operation was performed on an object.” Look for events where the object type is the Domain‑DNS object and the access mask includes
- Use Protected Users and tiering: Ensure accounts with replication rights are in Tier 0 and protected with MFA, PAWs, and JIT.
- Monitor for DCSync tools: Use network monitoring to detect tools like Mimikatz or Impacket communicating on RPC ports used for replication.
- Deploy Microsoft Defender for Identity: It specifically detects DCSync and DCShadow activities.
12.5 ACL Abuse: AdminSDHolder & SDProp
🔐 What is AdminSDHolder?
AdminSDHolder (Administrative SDHolder) is a special container in Active Directory (CN=AdminSDHolder,CN=System,DC=domain,DC=com) that holds the security descriptor (ACL) template for privileged accounts. Every 60 minutes (by default), a process called SDProp (Security Descriptor Propagator) runs and compares the ACLs of all protected accounts and groups against the AdminSDHolder object. If any differences are found, SDProp resets the ACLs on those objects to match AdminSDHolder.
Protected accounts and groups include: Domain Admins, Enterprise Admins, Schema Admins, Administrators, and other built‑in privileged groups. Also, any user who is a member of these groups is protected.
⚔️ How Attackers Abuse AdminSDHolder
If an attacker gains write access to the AdminSDHolder object (e.g., by modifying its ACL), they can plant a backdoor that will be propagated to all protected accounts and groups every 60 minutes. For example, they could add “Everyone” with Full Control to AdminSDHolder. After SDProp runs, every protected account and group will have “Everyone” with Full Control – a massive privilege escalation.
Common abuse: Adding a user with “GenericAll” or “WriteOwner” on AdminSDHolder, so that user gains full control over all privileged objects after the next SDProp run.
🛡️ Defending Against AdminSDHolder Abuse
- Monitor changes to AdminSDHolder: Enable auditing on the AdminSDHolder object. Look for Event ID 5136 (modification) on CN=AdminSDHolder. Alert on any changes – they should be extremely rare.
- Restrict write access to AdminSDHolder: By default, only Domain Admins and SYSTEM have full control. Ensure no other accounts have write permissions. Use ADSI Edit or PowerShell to check:
Get-ACL "AD:CN=AdminSDHolder,CN=System,DC=contoso,DC=com" | Format-List - Treat AdminSDHolder as Tier 0: Same protection as domain controllers.
- Use tools like PingCastle: It checks for misconfigurations in AdminSDHolder.
📋 SDProp Interval
The default SDProp interval is 60 minutes. You can change it via registry on the PDC emulator (not recommended unless necessary). To force SDProp to run immediately (for testing):
# On PDC emulator
Invoke-ADSDPropagation
12.6 SMB/LDAP Signing & Channel Binding
📡 SMB Signing
SMB signing ensures that SMB packets are digitally signed at the packet level, preventing man‑in‑the‑middle attacks such as SMB relay. When signing is enabled, both the client and server sign each packet, and the recipient verifies the signature. If signing is required, attackers cannot modify or relay SMB traffic.
Configuration:
Microsoft network server: Digitally sign communications (always)– Require signing on the server.Microsoft network client: Digitally sign communications (always)– Require signing on the client.
These settings are in Group Policy under Computer Configuration → Policies → Windows Settings → Security Settings → Local Policies → Security Options. For maximum security, set both to “Enabled” (require signing). Note that this may impact performance on very busy file servers.
🔏 LDAP Signing and Channel Binding
LDAP signing requires that LDAP traffic be signed, preventing modification of LDAP queries and responses. LDAP channel binding binds the LDAP session to the outer TLS channel, preventing relay attacks where an attacker forwards LDAP authentication.
Configuration (via Group Policy):
Domain controller: LDAP server signing requirements– Set to “Require signing”.Network security: LDAP client signing requirements– Set to “Require signing”.Domain controller: LDAP server channel binding token requirements– Set to “Always” (this requires LDAP over TLS/SSL).
These settings are critical to prevent NTLM relay attacks (e.g., the PrinterBug or PetitPotam).
📊 Why These Matter
- Without SMB signing: Attackers can perform SMB relay attacks, where they forward authentication from a client to a server, gaining access without knowing credentials.
- Without LDAP signing/channel binding: Attackers can relay LDAP authentication (e.g., via PetitPotam) to force a domain controller to authenticate to a rogue server, leading to credential theft.
🛡️ Best Practices
- Enable SMB signing on all systems (especially domain controllers and file servers).
- Require LDAP signing and channel binding on all domain controllers.
- Monitor for relay attacks: Event ID 4887 (LDAP signing required but not used), and SMB signing failures.
- Use Extended Protection for Authentication (EPA) for web applications.
12.7 LAPS (Local Administrator Password Solution)
🔑 What is LAPS?
LAPS (Local Administrator Password Solution) is a Microsoft tool that automatically manages local administrator passwords on domain‑joined computers. It solves the problem of identical local admin passwords across many machines – a common vector for lateral movement in Pass‑the‑Hash attacks.
⚙️ How LAPS Works
- LAPS is installed on each workstation/server (via Group Policy or endpoint management).
- A client‑side extension periodically generates a new, random password for the local administrator account (or any specified local account).
- The password is stored in Active Directory as a confidential attribute (
ms-Mcs-AdmPwd) on the computer object. The password is encrypted during transmission and storage. - Only authorised users (e.g., helpdesk) are granted read access to this attribute. They can retrieve the password when needed (e.g., for remote support).
- The old password is then changed after use.
📦 Deploying LAPS
Steps:
- Download LAPS from Microsoft and install on management workstations.
- Extend the AD schema to add the LAPS attributes (run
Update-LapsADSchema). - Delegate permissions to computer objects so that machines can update their own
ms-Mcs-AdmPwdattribute. Use theSet-LapsADComputerSelfPermissioncmdlet. - Create a GPO to deploy the LAPS client. The GPO should be linked to OUs containing computers.
- Configure LAPS policy in the GPO:
- Password complexity (recommended 14+ characters).
- Password expiration (e.g., 30 days).
- Enable local admin password management.
- Delegate read access to the password attribute to authorised helpdesk groups (e.g., “Helpdesk” group).
- Test on a pilot OU before broad deployment.
🛡️ Security Benefits
- Unique local admin passwords for every machine – if one machine is compromised, its local admin password cannot be used on others.
- Passwords are strong and rotated regularly.
- Auditing: Access to passwords is logged in AD (Event ID 4662).
📊 Monitoring LAPS
- Monitor Event ID 10003 (password successfully changed) and 10004 (password retrieval) on clients.
- Audit access to LAPS passwords via AD auditing (enable success/failure on the
ms-Mcs-AdmPwdattribute). - Periodically verify that all machines have a valid LAPS password (report using
Get-LapsADPassword).
12.8 Credential Guard & Protected Users
🛡️ Windows Defender Credential Guard
Credential Guard uses virtualization‑based security to isolate secrets (like NTLM hashes and Kerberos tickets) in a protected environment that even a privileged attacker cannot access. It prevents attacks like Pass‑the‑Hash and Pass‑the‑Ticket by ensuring that LSASS (Local Security Authority Subsystem Service) does not store secrets in a way that can be read by malware.
How it works: Credential Guard runs a secure, isolated instance of LSASS (called Isolated LSASS) in a virtualised container. The main LSASS communicates with it only when necessary. An attacker with admin rights cannot read the isolated LSASS memory.
Requirements: Windows 10/11 Enterprise or Education, Windows Server 2016+, UEFI lock, Virtualization-Based Security enabled, TPM 2.0 recommended.
Enable via Group Policy:
Computer Configuration → Administrative Templates → System → Device Guard → Turn on Virtualization Based Security.- Set to “Enabled” and select “Enable with Credential Guard”.
🔒 Protected Users Group
As covered in Module 6, the Protected Users group applies non‑configurable security protections to its members:
- No NTLM authentication.
- No Kerberos delegation.
- No DES or RC4 encryption in Kerberos (requires AES).
- No credential delegation (CredSSP).
- Kerberos ticket lifetime reduced to 4 hours.
Add all administrative accounts to Protected Users. This significantly reduces their attack surface.
📋 Best Practices
- Enable Credential Guard on all domain‑joined machines, especially on administrative workstations and servers.
- Add all privileged accounts to Protected Users.
- Use PAWs (Privileged Access Workstations) for admins.
- Monitor for attempts to use NTLM or weak Kerberos by Protected Users (they will generate failures).
12.9 Logging & Monitoring (Critical Event IDs)
🔍 Why Logging Matters
Without comprehensive logging, you cannot detect attacks in progress or investigate incidents. Active Directory generates a wealth of security events that, when properly collected and analysed, can reveal attacker activity. This section lists the most critical event IDs to monitor and alert on.
📊 Critical Event ID Reference Table
| Event ID | Description | Why Monitor |
|---|---|---|
| 4618 | A monitored security event pattern occurred | Often used by SIEM rules for correlation |
| 4624 | An account was successfully logged on | Track all logons, especially for privileged accounts. Look for logon type 3 (network) from unusual sources. |
| 4625 | An account failed to log on | Potential brute‑force attack. Monitor for many failures on a single account. |
| 4634 | An account was logged off | Useful for session duration analysis. |
| 4648 | A logon was attempted using explicit credentials | Indicates a user ran a process as another user (e.g., runas). May indicate lateral movement. |
| 4672 | Special privileges assigned to new logon | Indicates a user logged on with admin rights (e.g., as Administrator or with SeTcbPrivilege). Correlate with 4624. |
| 4662 | An operation was performed on an object | Monitor for access to sensitive objects, especially with control access rights (e.g., DCSync). |
| 4720 | A user account was created | Unauthorised account creation could indicate a backdoor. |
| 4728 / 4732 / 4756 | Member added to security group | Especially monitor additions to privileged groups (Domain Admins, etc.). |
| 4735 / 4737 | Security group changed | Changes to privileged group settings. |
| 4740 | A user account was locked out | Multiple lockouts may indicate brute‑force or password guessing. |
| 4768 | A Kerberos authentication ticket (TGT) was requested | Monitor for requests from unusual accounts or for long lifetimes (potential Golden Ticket). |
| 4769 | A Kerberos service ticket was requested | Monitor for many requests from same user (Kerberoasting), or RC4 encryption if AES is enforced. |
| 4776 | The domain controller attempted to validate the credentials for an account | NTLM authentication events. Monitor for failures on admin accounts. |
| 5136 | A directory service object was modified | Monitor changes to critical objects (AdminSDHolder, Domain Controllers OU). |
| 5137 | A directory service object was created | Creation of new objects in sensitive locations. |
| 5141 | A directory service object was deleted | Deletion of critical objects. |
| 4887 | Certificate Services approved a certificate request | Monitor for rogue certificate issuance (ADCS attacks). |
🛠️ Enabling Auditing
Use Group Policy to enable advanced auditing on domain controllers and critical servers. At minimum, enable:
- Account Logon (Success, Failure)
- Account Management (Success, Failure)
- DS Access (Success, Failure)
- Logon/Logoff (Success, Failure)
- Privilege Use (Success, Failure)
- System (Success, Failure)
📈 SIEM Integration
Forward all critical events to a SIEM (e.g., Azure Sentinel, Splunk, QRadar). Create alerts for:
- Any addition to a privileged group.
- Any DCSync attempt (4662 with replication GUID).
- Any change to AdminSDHolder.
- Multiple 4769 from same user for different SPNs.
- Logons of Tier 0 accounts from non‑PAW machines.
12.10 Advanced Audit Policy & System Access Control Lists (SACLs)
🔐 What are SACLs?
A System Access Control List (SACL) is part of an object's security descriptor that specifies what operations on the object should be audited. For example, you can set a SACL on the Domain Admins group to audit every time a member is added. SACLs provide granular control beyond the basic audit policies.
🛠️ Configuring SACLs
You can configure SACLs on OUs, groups, or individual objects using:
- Active Directory Users and Computers (Advanced Features): Right‑click object → Properties → Security → Advanced → Auditing tab.
- PowerShell: Use
Set-ACLwith an audit rule.
Example: Audit all writes to the Domain Admins group.
$group = Get-ADGroup "Domain Admins" -Properties distinguishedName
$path = "AD:$($group.distinguishedName)"
$acl = Get-Acl -Path $path
$auditRule = New-Object System.Security.AccessControl.FileSystemAuditRule("Everyone", "Write", "Success")
$acl.AddAuditRule($auditRule)
Set-Acl -Path $path -AclObject $acl
📋 Recommended SACLs for Critical Objects
- AdminSDHolder: Audit all writes (Success, Failure).
- Domain Admins group: Audit member additions (Success).
- Domain Controllers OU: Audit creation/deletion of DCs.
- Schema partition: Audit modifications.
- Specific users (e.g., CEO): Audit failed logons (Failure).
🔄 Global Object Access Auditing
You can set global SACLs via Group Policy that apply to all objects of a certain type. For example, to audit all file servers for Everyone.
Configuration: Computer Configuration → Policies → Windows Settings → Security Settings → Advanced Audit Policy Configuration → System Audit Policies – Local Group Policy Object → Global Object Access Auditing.
📊 Advanced Audit Policy
The “Advanced Audit Policy” settings (under Computer Configuration → Policies → Windows Settings → Security Settings → Advanced Audit Policy Configuration) provide finer granularity than the legacy audit settings. Enable at least:
- Account Logon → Audit Kerberos Authentication Service: Success, Failure
- Account Logon → Audit Kerberos Service Ticket Operations: Success, Failure
- Account Management → Audit Security Group Management: Success, Failure
- Account Management → Audit User Account Management: Success, Failure
- DS Access → Audit Directory Service Access: Success, Failure (needs SACLs)
- DS Access → Audit Directory Service Changes: Success, Failure
- Logon/Logoff → Audit Logon: Success, Failure
- Privilege Use → Audit Sensitive Privilege Use: Success, Failure
12.11 ADCS Attack Vectors (ESC1‑ESC8)
🔐 What is ADCS?
Active Directory Certificate Services (ADCS) is Microsoft's PKI implementation. It issues certificates for authentication (smart cards, SSL/TLS, etc.). Misconfigurations in ADCS can lead to severe vulnerabilities, as documented by SpecterOps in their research “Certified Pre‑Owned”. They identified eight escalation vectors (ESC1‑ESC8).
⚠️ Common ADCS Attack Vectors
- ESC1 – Misconfigured Certificate Templates: If a template allows a low‑privileged user to request a certificate with “Subject Alternative Name” (SAN) and “Enrollee Supplies Subject” enabled, they can request a certificate as any user (e.g., Domain Admin).
- ESC2 – Misconfigured Template with Any Purpose: Templates with “Any Purpose” EKU can be used for authentication and other purposes, allowing an attacker to issue a certificate for any use.
- ESC3 – Enrollment Agent Templates: If an attacker can get a certificate with Enrollment Agent rights, they can request certificates on behalf of others.
- ESC4 – Access Control Vulnerabilities: Weak permissions on certificate templates allow attackers to modify them (e.g., add themselves as enrollees).
- ESC5 – Weak CA Security: Permissions on the CA itself (e.g., allowing low‑privileged users to manage CA) can lead to compromise.
- ESC6 – EDITF_ATTRIBUTESUBJECTALTNAME2: A CA setting that allows enrollees to specify SAN, enabling certificate spoofing.
- ESC7 – Vulnerable CA Interface: If the CA web enrollment interface is enabled and misconfigured, attackers can abuse it.
- ESC8 – NTLM Relay to CA Web Enrollment: If AD CS web enrollment is enabled, attackers can relay NTLM authentication to obtain a certificate for a user.
🛡️ Mitigations
- Audit certificate templates: Review all templates for dangerous settings (SAN in subject, enrollee supplies subject, weak EKUs). Disable or restrict them.
- Restrict enrollment permissions: Only allow authorised users/groups to enrol in sensitive templates.
- Disable NTLM for web enrollment: Ensure CA web enrollment requires HTTPS and Extended Protection for Authentication.
- Enable auditing on CA: Monitor Event ID 4887 (certificate issued) and investigate unusual requests.
- Use tools like PSPKIAudit or Certify: Regularly scan for misconfigurations.
12.12 Microsoft Defender for Identity
🛡️ What is Microsoft Defender for Identity?
Microsoft Defender for Identity (formerly Azure Advanced Threat Protection) is a cloud‑based security solution that monitors on‑premises Active Directory signals to identify, detect, and investigate advanced threats, compromised identities, and malicious insider actions. It uses machine learning and behavioural analytics to detect suspicious activities.
🔍 Key Capabilities
- Detection of known attack techniques: Pass‑the‑Hash, Pass‑the‑Ticket, Golden Ticket, DCSync, etc.
- Behavioural analytics: Detects unusual logon patterns, anomalous user behaviour, and lateral movement.
- Alert prioritisation: Provides a risk score and actionable guidance.
- Integration with Microsoft 365 Defender: Correlates alerts with identities and endpoints.
- Identity security posture assessments: Recommends hardening measures.
⚙️ How It Works
Defender for Identity installs sensors on domain controllers and AD FS servers. These sensors monitor network traffic, Event Logs, and ETW (Event Tracing for Windows) to send metadata to the Defender for Identity cloud service for analysis.
Deployment steps:
- Create a Defender for Identity instance in the Microsoft 365 Defender portal.
- Download and install the sensor on each domain controller.
- Configure the sensor to communicate with the cloud.
- Integrate with other Microsoft 365 Defender components (optional).
📊 Example Alerts
- Suspicious DCSync activity: Detects when a non‑DC attempts replication.
- Golden Ticket usage: Detects anomalies in Kerberos ticket lifetimes.
- Honeytoken account compromise: You can set fake “honeytoken” accounts; any activity triggers an alert.
- Unusual lateral movement: Detects Pass‑the‑Hash and Pass‑the‑Ticket.
✅ Best Practices
- Deploy Defender for Identity on all domain controllers.
- Integrate with Microsoft 365 Defender for a unified view.
- Create honeytoken accounts (e.g., “svc_honey”) with no real use, and monitor them.
- Respond to alerts promptly and investigate using the detailed timeline.
12.13 Purple Team Exercises for AD
🎯 What is a Purple Team Exercise?
A Purple Team exercise is a collaborative activity where the Red Team (attackers) and Blue Team (defenders) work together to test and improve detection and response capabilities. In the context of AD, it involves simulating realistic attacks and measuring how well the defensive controls and monitoring detect them.
🔄 Why Purple Team for AD?
- Validate that your monitoring tools (SIEM, Defender for Identity) are correctly configured to detect common attack techniques.
- Identify gaps in logging – are the right events being generated and collected?
- Test incident response procedures in a controlled environment.
- Improve communication between teams.
📋 Common AD Attack Simulations
- Kerberoasting: Use Rubeus to request service tickets and crack them. Monitor for Event ID 4769 anomalies.
- Pass‑the‑Hash: Use Mimikatz to extract a hash and authenticate to another machine. Monitor for Event ID 4624 logon type 3 with NTLM.
- DCSync: Use Mimikatz to simulate DCSync. Monitor for Event ID 4662 with replication GUID.
- Golden Ticket: Forge a Golden Ticket and attempt to access a resource. Monitor for Event ID 4768 with abnormal lifetimes.
- ACL abuse: Modify a group membership via a delegated ACL. Monitor for Event ID 4728.
🛠️ Tools for Purple Team
- Atomic Red Team: A library of tests mapped to MITRE ATT&CK. Has many AD‑specific tests.
- Rubeus, Mimikatz, PowerSploit: For simulating attacks.
- BloodHound: To discover attack paths before and after.
- Attack‑Surface‑Analyzer: To compare baseline and after‑exercise state.
📊 Measuring Success
- Detection time: How long between the attack and an alert?
- Coverage: Which attacks were detected? Which were missed?
- False positives: Were there unnecessary alerts?
- Investigation depth: Could the team trace the attack timeline?
12.14 Incident Response for Active Directory Compromise
🚨 When AD is Compromised
An Active Directory compromise is a worst‑case scenario. Attackers with Domain Admin access can disable security controls, create backdoors, and exfiltrate data. A structured incident response (IR) plan is essential to contain, eradicate, and recover.
📋 IR Phases for AD
- Preparation: Have a documented IR plan, backups, and a clean, isolated environment for analysis. Ensure you have offline copies of critical system state backups.
- Identification: Detect the compromise via alerts (e.g., DCSync detection, unusual logons). Confirm the scope: which accounts, which DCs, what actions.
- Containment:
- Isolate compromised systems from the network (disable network adapters, but do not shut down – preserve memory).
- Reset passwords of compromised accounts (but beware: if KRBTGT is compromised, password reset alone is insufficient).
- If KRBTGT is compromised, prepare to rotate it twice.
- Enable enhanced logging on all DCs (if not already).
- Eradication:
- Identify and remove attacker‑created accounts, groups, and backdoors.
- Restore compromised objects from backup (if needed).
- For KRBTGT compromise: change KRBTGT password twice (with a 24‑hour interval). This invalidates Golden Tickets.
- Patch the vulnerability that led to the initial compromise.
- Recovery:
- Promote new, clean DCs if any DCs were compromised.
- Reset all user passwords (if widespread credential theft).
- Restore services and monitor for signs of re‑infection.
- Lessons Learned:
- Analyse the root cause.
- Update security controls and monitoring.
- Improve the IR plan.
🔑 Key Actions for Specific Compromises
| Compromise Type | Immediate Action |
|---|---|
| KRBTGT hash stolen | Change KRBTGT password twice (with 24‑hour delay). |
| Domain Admin account compromised | Reset password, revoke tokens, check for backdoors created. |
| DCSync detected | Assume all hashes are compromised. Force password resets for all users (or at least privileged ones). |
| Golden Ticket used | Change KRBTGT password twice, and check for other persistence. |
| DC compromised |
🛡️ Post‑Incident Hardening
- Implement all mitigations from this module.
- Conduct a Purple Team exercise to validate new controls.
- Increase logging and monitoring.
- Review and reduce privileged group memberships.
🎓 Module 12 : AD Security – Threats & Hardening Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This module covered the most critical attack techniques and defensive controls for Active Directory. You are now equipped to assess, harden, and defend your AD environment against sophisticated adversaries.
Module 13 : Identity Management & Privileged Access Management (PAM)
This module provides a comprehensive deep dive into Identity Management and Privileged Access Management (PAM) in the context of Active Directory and hybrid environments. You will learn about Microsoft Identity Manager (MIM), Privileged Identity Management (PIM) in Azure, Just‑In‑Time (JIT) administration, Privileged Access Workstations (PAW), the tiered administration model, authentication policies and silos, managing service accounts (gMSA, sMSA), identity lifecycle management, integrating third‑party identity stores, and identity governance and reporting. These concepts are essential for designing and operating a secure, compliant, and manageable identity infrastructure in modern enterprises.
13.1 Microsoft Identity Manager (MIM)
🔍 What is Microsoft Identity Manager?
Microsoft Identity Manager (MIM) is an on‑premises identity management solution that helps organisations manage users, credentials, policies, and access across heterogeneous environments. It is the successor to Forefront Identity Manager (FIM) and provides a robust platform for synchronising identities from multiple data sources (HR systems, databases, directories) into Active Directory and other connected systems.
MIM acts as a central hub that connects your HR system (like SAP, Workday) to Active Directory. When an employee joins, MIM can automatically create their AD account, assign groups, and provision access to other systems.
🧩 Key Components of MIM
- MIM Service: The core synchronisation engine that processes identity data and applies business rules.
- MIM Portal: A web‑based interface for self‑service (password reset, group management) and administrative tasks.
- MIM Synchronization Service: Handles importing and exporting data from connected data sources (Active Directory, HR databases, etc.).
- MIM Password Registration Portal: Allows users to register for self‑service password reset.
- MIM Certificate Management (CM): Manages digital certificates (optional).
- MIM Privileged Access Management (PAM): A separate component for JIT administration (covered in 13.3).
🔄 Common Use Cases for MIM
- Automated user provisioning: Create, update, and disable user accounts in AD based on HR data.
- Group management: Automate group memberships based on role, department, or location.
- Self‑service password reset (SSPR): Allow users to reset their own passwords without helpdesk intervention.
- Self‑service group management: Allow users to request membership in groups with approval workflows.
- Identity lifecycle management: Automate the entire joiner‑mover‑leaver process.
- Privileged Access Management (PAM): Isolated forest for JIT administration.
⚙️ How MIM Works
MIM uses a metaverse (central database) to store aggregated identity information from multiple connected data sources. Connectors (also called management agents) import data from source systems (e.g., HR) and export data to target systems (e.g., AD). Synchronisation rules define how attributes map between systems and what actions to take (e.g., create user if not exists).
- Import: MIM imports data from HR system (employee ID, name, department, manager).
- Synchronise: The sync engine compares imported data with the metaverse and AD.
- Provision: If a new employee is found, MIM creates a user object in AD, sets attributes, and adds to default groups.
- Export: Changes are exported to AD.
📋 MIM Architecture Overview
HR System (SAP, Workday) → [MIM Connector] → MIM Sync Engine → Metaverse → [MIM Connector] → Active Directory
↓
MIM Portal (Self-Service, Approvals)
🛡️ Security Considerations
- MIM itself is a Tier 0 system – it controls identity creation and should be protected like a domain controller.
- Use dedicated service accounts with least privilege.
- Enable auditing and monitoring for MIM changes.
- Regularly back up the MIM configuration and metaverse database.
13.2 Privileged Identity Management (PIM) in Azure AD
☁️ What is Azure AD Privileged Identity Management (PIM)?
Azure AD Privileged Identity Management (PIM) is a service in Azure Active Directory that enables you to manage, control, and monitor access to important resources in your organisation. PIM provides just‑in‑time (JIT) privileged access to Azure AD roles, Azure resources, and other Microsoft online services (e.g., Exchange Online, SharePoint Online). It is a key component of a modern privileged access strategy.
PIM ensures that no one has permanent admin rights. If you need to be an admin, you request elevation for a specific time, and after approval, you get temporary access. This limits the window of exposure.
🔑 Key Features of PIM
- Just‑In‑Time (JIT) access: Users request activation of eligible roles for a limited time.
- Time‑bound access: Role assignments can have a start and end time (eligible or active).
- Approval workflows: Require approval from designated approvers before activation.
- Multi‑Factor Authentication (MFA) enforcement: Force users to authenticate with MFA before activating a role.
- Justification and audit trail: Users must provide a reason for activation; all actions are logged.
- Access reviews: Regularly review who has eligible and active assignments.
- Notifications and alerts: Get alerts for suspicious activities.
🔄 PIM for Azure AD Roles vs Azure Resources
- Azure AD roles: Global Administrator, User Administrator, etc. These manage Azure AD itself.
- Azure resources: Subscriptions, resource groups, individual resources (e.g., VMs). PIM can manage just‑in‑time access to these as well.
⚙️ How PIM Works
- Make a role eligible: An administrator assigns a user to a role (e.g., Global Administrator) as “eligible” rather than “active”. The user has no permanent rights.
- Activation request: When the user needs to perform admin tasks, they go to the PIM portal and request activation, specifying duration and justification.
- Approval (if required): Designated approvers receive a notification and approve or deny the request.
- MFA verification: The user must complete MFA (if required by policy).
- Temporary elevation: The user gains the role for the requested duration. All actions are logged.
- Automatic deactivation: After the time expires, the role is automatically deactivated.
📋 PIM Licensing
PIM requires Azure AD Premium P2 licenses for users who will be assigned eligible roles or who will be approvers. It is included in Microsoft 365 E5 and Enterprise Mobility + Security E5.
🛡️ Best Practices for PIM
- Enforce MFA for all role activations.
- Set reasonable maximum activation durations (e.g., 4 hours).
- Require approval for highly privileged roles (Global Admin).
- Conduct regular access reviews to remove unnecessary eligible assignments.
- Integrate PIM alerts with your SIEM.
- Use PIM for break‑glass accounts with extreme caution – they should have no standing privileges.
13.3 Just‑In‑Time (JIT) Administration
⏱️ What is Just‑In‑Time Administration?
Just‑In‑Time (JIT) administration is a security principle where users are granted elevated privileges only for the duration of a specific task, rather than having permanent standing privileges. JIT reduces the attack surface by eliminating always‑on admin accounts that attackers can target. JIT can be implemented on‑premises (with MIM PAM) or in the cloud (with Azure AD PIM).
🔑 Benefits of JIT
- Reduced attack surface: No permanent privileged accounts to steal.
- Minimised blast radius: If an account is compromised, its privileges are temporary.
- Improved auditing: Every elevation is logged with justification and approval.
- Compliance: Meets requirements for least privilege and access control.
🏢 On‑Premises JIT with MIM PAM
MIM Privileged Access Management (PAM) uses a bastion forest – a separate, highly secured Active Directory forest that is trusted by the production forest. Users request elevation, and MIM grants time‑bound membership in privileged groups in the bastion forest. The bastion forest then provides access to production resources via trust.
MIM PAM workflow:
- Admin requests elevation for a specific role (e.g., Domain Admin) via the MIM portal.
- Request is approved (automatically or by a manager).
- MIM adds the admin's user account to a shadow group in the bastion forest for a limited time.
- The admin uses a PAW to log on to the bastion forest, which gives them access to production resources via trust.
- After the time expires, the membership is automatically removed.
☁️ Cloud JIT with Azure AD PIM
As covered in 13.2, Azure AD PIM provides JIT for Azure AD roles and Azure resources. It is simpler to set up than MIM PAM but only covers cloud resources and Azure AD roles. For on‑premises AD, you still need MIM PAM or other solutions.
🔄 Hybrid JIT
In a hybrid environment, you may need JIT for both on‑prem and cloud. This can be achieved by combining MIM PAM (for on‑prem) and Azure AD PIM (for cloud). Some organisations also use third‑party PAM solutions (CyberArk, BeyondTrust) that integrate with both.
📋 Implementing JIT – Key Considerations
- Plan the approval workflow: Who approves elevation for which roles? Use multi‑step approval for high‑risk roles.
- Define maximum elevation times: Typically 4‑8 hours for admin tasks.
- Integrate with ticketing systems: Require a ticket number for justification.
- Ensure high availability: The JIT system itself must be resilient.
- Monitor and alert: Track all elevation requests and activations.
13.4 Privileged Access Workstations (PAW)
🖥️ What is a Privileged Access Workstation?
A Privileged Access Workstation (PAW) is a dedicated, hardened workstation used exclusively for administrative tasks. It is designed to protect privileged accounts from credential theft and other attacks. PAWs are a cornerstone of Microsoft's privileged access strategy and are essential for Tier 0 and Tier 1 administrators.
A PAW is like a clean, locked‑down computer that you only use for admin work – no email, no web browsing, no document editing. It's your "clean room" for managing the kingdom.
🔒 Key Characteristics of a PAW
- Dedicated purpose: Used only for administration – no email, web browsing, or productivity applications.
- Hardened OS: Security baseline applied (e.g., Microsoft Security Compliance Toolkit).
- Application control: AppLocker or Windows Defender Application Control (WDAC) to allow only authorised administrative tools.
- Credential Guard: Enabled to protect LSASS from credential theft.
- BitLocker: Full disk encryption.
- Network isolation: Preferably on a dedicated management network segment, with restricted internet access (or only through a secure proxy).
- Regular patching: Kept up‑to‑date with security patches.
- Separate administrative accounts: Only privileged accounts (Tier 0 or Tier 1) are allowed to log on.
📋 PAW Deployment Options
- Physical PAW: A dedicated physical machine. Most secure but more expensive.
- Virtual PAW: A virtual machine on a secure host (e.g., a dedicated virtualization server). Allows easier management and isolation.
- Cloud‑based PAW: Using Windows 365 (Cloud PC) or Azure Virtual Desktop to provide a cloud‑hosted administrative workstation. This can be very effective for hybrid environments.
🔧 Configuring a PAW
- Fresh OS installation: Install Windows 10/11 Enterprise or Windows Server (for server management).
- Apply security baseline: Use the Microsoft Security Compliance Toolkit to apply a recommended security configuration.
- Enable Credential Guard: Through Group Policy or registry.
- Configure AppLocker/WDAC: Create rules to allow only necessary administrative tools (e.g., RSAT, PowerShell, custom scripts).
- Enable BitLocker: Protect data at rest.
- Join to an admin-only domain: Consider a separate administrative forest or a dedicated OU with strict policies.
- Restrict logon: Only allow privileged accounts to log on (via user rights assignments).
📊 PAW for Tier 0 vs Tier 1
- Tier 0 PAW: Used for managing domain controllers, Active Directory, and other Tier 0 assets. Must be extremely locked down. Often uses smart card logon.
- Tier 1 PAW: Used for managing servers (file servers, application servers). May have slightly more relaxed controls but still hardened.
🛡️ Best Practices
- Enforce smart card or Windows Hello for Business logon on PAWs.
- Implement strict patch management – PAWs should be updated promptly.
- Monitor PAWs for signs of compromise (unusual logons, processes).
- Ensure PAWs are physically secured (if physical).
- Document the configuration and maintain a golden image.
13.5 Tiered Administration Model
🏛️ What is the Tiered Administration Model?
The tiered administration model is a security architecture that separates administrative responsibilities into tiers based on the criticality of the systems being managed. It is a key component of Microsoft's Enterprise Access Model and helps prevent credential theft and lateral movement. The model defines three tiers:
- Tier 0 (Identity and Control Plane): The highest level – includes domain controllers, Active Directory, Azure AD Connect, AD FS, and any system with direct control over the identity store. Compromise of Tier 0 gives the attacker complete control over the entire forest.
- Tier 1 (Server and Application Infrastructure): Includes file servers, application servers, database servers, and other infrastructure servers that do not control identity. Compromise gives access to application data and server control, but not to identity.
- Tier 2 (User Workstations and Devices): End‑user devices – workstations, laptops, tablets. Compromise gives a foothold but not direct access to servers or identity.
🔒 The Golden Rule: No Lateral Movement Between Tiers
The core principle is that administrative accounts from a higher tier can log on to lower‑tier systems, but lower‑tier accounts cannot log on to higher‑tier systems. For example:
- A Tier 0 admin (using their Tier 0 account) can log on to a file server (Tier 1) to perform maintenance.
- A Tier 1 admin (using their Tier 1 account) must never log on to a domain controller (Tier 0). If they need to perform a Tier 0 task, they must use a separate Tier 0 account and a PAW.
🛡️ Implementing the Tiered Model
- Separate administrative accounts: Each administrator should have a separate account for each tier they manage (e.g., user_t0, user_t1).
- Privileged Access Workstations (PAWs): Use PAWs for Tier 0 and Tier 1 administration.
- Restrict logon rights: Use Group Policy to restrict where accounts can log on. For example, deny Tier 0 accounts from logging on to Tier 1 and Tier 2 systems (except via PAW).
- Network segmentation: Place Tier 0 systems on a separate management network with strict firewall rules.
- Monitoring: Detect and alert on any logon of a higher‑tier account to a lower‑tier system (which should not happen).
📋 Example: Administrator Accounts by Tier
| Admin | Tier 0 Account | Tier 1 Account | Tier 2 Account |
|---|---|---|---|
| Alice (Senior Admin) | alice_t0 | alice_t1 | alice (standard user) |
| Bob (Server Admin) | Not used | bob_t1 | bob (standard user) |
| Carol (Helpdesk) | Not used | Not used | carol_t2, carol (standard) |
📈 Benefits of the Tiered Model
- Contains breaches: An attacker who compromises a Tier 2 workstation cannot directly access Tier 1 or Tier 0.
- Reduces attack surface: No standing privileged accounts on lower‑tier systems.
- Simplifies monitoring: You can focus on cross‑tier logons as high‑risk events.
13.6 Authentication Policies & Authentication Silos
🔐 What are Authentication Policies?
Authentication policies are a feature introduced in Windows Server 2012 R2 that allow you to restrict how and where privileged accounts can authenticate. They work by controlling the issuance of Kerberos tickets and applying conditions to authentication requests. Authentication policies are configured on the PDC Emulator and apply to users, computers, or services.
Authentication policies let you say: "This admin account can only be used from a specific PAW, and only between 9 AM and 5 PM, and only for Kerberos authentication (no NTLM)."
📋 Key Components
- Authentication policy: Defines the conditions for authentication (e.g., allowed TGT lifetime, require Kerberos armoring, require specific claims).
- Authentication silo: A container that groups users and computers that share the same authentication policy. Silos can be used to isolate highly privileged accounts (e.g., all Tier 0 admins in a silo).
⚙️ How Authentication Policies Work
When a user in a silo attempts to authenticate, the KDC checks the authentication policy associated with the silo. The policy can enforce:
- Allowed authentication methods: Require Kerberos, disallow NTLM.
- Claims and compound authentication: Require device claims (e.g., device must be compliant).
- TGT lifetime: Set a shorter TGT lifetime for privileged accounts.
- Kerberos armoring (FAST): Require armored Kerberos requests.
- Access control conditions: e.g., only allow authentication from specific IP ranges or devices.
🛠️ Configuring Authentication Policies and Silos
Authentication policies and silos are managed using the Active Directory Administrative Center (ADAC) or PowerShell.
PowerShell example:
# Create an authentication silo
New-ADAuthenticationSilo -Name "Tier0 Admins" -Description "Silo for Tier 0 admin accounts"
# Create an authentication policy
New-ADAuthenticationPolicy -Name "Tier0 Policy" -UserAllowedToAuthenticateFrom "O:BAG:BAD:(A;;CC;;;S-1-5-21-123456789-1234567890-123456789-112233)" -Enforce
# Add users and computers to the silo
Add-ADAuthenticationSiloMember -Identity "Tier0 Admins" -Members "CN=Alice,OU=Admins,DC=contoso,DC=com"
🔄 Integration with Tiered Model
Authentication silos are an excellent way to enforce the tiered model. For example, you can create a silo for Tier 0 accounts and configure a policy that requires Kerberos armoring and short TGT lifetimes. You can also restrict authentication to only allow logons from PAWs (using the UserAllowedToAuthenticateFrom attribute).
📈 Benefits
- Enforces least privilege at the authentication level.
- Prevents NTLM usage for privileged accounts.
- Reduces the risk of credential theft by limiting where and when accounts can authenticate.
13.7 Managing Service Accounts (gMSA, sMSA)
🔑 The Problem with Traditional Service Accounts
Traditional service accounts are often manually managed, with passwords that rarely change and are stored in scripts or configuration files. This makes them a prime target for attackers (Kerberoasting) and a management headache. Microsoft introduced Managed Service Accounts (MSAs) and Group Managed Service Accounts (gMSAs) to solve these problems.
📦 Standalone Managed Service Accounts (sMSA)
sMSAs are managed domain accounts that provide automatic password management and simplified SPN management. They are associated with a single computer. The password is automatically changed by the domain controller and known only to that computer. sMSAs were introduced in Windows Server 2008 R2.
Limitations: Can only be used on one computer. Not suitable for services running on multiple servers (e.g., web farms).
👥 Group Managed Service Accounts (gMSA)
gMSAs extend the concept to multiple servers. A gMSA is a domain account whose password is managed by the domain controller and can be retrieved by multiple computers in a group. gMSAs were introduced in Windows Server 2012.
Key features:
- Automatic password management (120‑character random password, changed every 30 days).
- SPN management – you can set SPNs on the gMSA.
- Can be used on multiple servers (ideal for load‑balanced services).
- No human interaction required – passwords are never known to administrators.
⚙️ Creating and Using a gMSA
Prerequisites:
- Active Directory schema must support gMSA (Windows Server 2012 or later).
- Domain functional level must be Windows Server 2012 or later.
- KDS root key must be created (to generate passwords).
Steps:
- Create the KDS root key (one‑time per forest):
Add-KdsRootKey -EffectiveTime (Get-Date).AddHours(-10) - Create the gMSA:
New-ADServiceAccount -Name "svc_webapp" -DNSHostName "svc_webapp.contoso.com" -PrincipalsAllowedToRetrieveManagedPassword "WEBFARM$" - On each server that needs to use the gMSA, install the account:
Install-ADServiceAccount -Identity "svc_webapp" - Configure your service (e.g., IIS app pool) to run as the gMSA (using the format
domain\svc_webapp$).
🔄 gMSA vs sMSA vs Standard Service Account
| Feature | Standard Account | sMSA | gMSA |
|---|---|---|---|
| Password management | Manual | Automatic | Automatic |
| Password strength | User‑defined | Random, complex | Random, complex (120 chars) |
| Supports multiple servers | Yes (but same password) | No | Yes |
| SPN management | Manual | Manual | Can be set on account |
| Kerberoasting risk | High (weak passwords) | Low | Very low (impossible to crack) |
| Introduced in | Always | 2008 R2 | 2012 |
🛡️ Best Practices for Service Accounts
- Use gMSAs wherever possible for services that run on multiple servers.
- Use sMSAs for single‑server services.
- For legacy applications that cannot use gMSAs, use strong, randomly generated passwords (20+ characters) and rotate them regularly using a privileged access management solution.
- Never run services as Domain Admins or other highly privileged accounts.
- Audit service account usage and alert on anomalies.
13.8 Identity Lifecycle Management (ILM)
🔄 What is Identity Lifecycle Management?
Identity Lifecycle Management (ILM) is the process of managing digital identities from creation to deletion, typically following the joiner‑mover‑leaver model. ILM ensures that users have the right access at the right time, and that access is removed when no longer needed. It is a core function of identity governance.
ILM automates the process of creating accounts when someone joins, updating access when they change roles, and disabling accounts when they leave. This reduces risk and administrative overhead.
📋 The Joiner‑Mover‑Leaver Model
- Joiner: When an employee joins, an identity must be created in Active Directory (and other systems). This includes setting up user account, assigning groups (based on role/department), creating home directory, and provisioning email. ILM automates this based on data from HR.
- Mover: When an employee changes roles (e.g., promotion, transfer), their access needs to be updated. Old group memberships may be removed, new ones added. ILM can trigger these changes based on HR data (e.g., new department code).
- Leaver: When an employee leaves, all access must be promptly revoked. ILM can disable the AD account, remove group memberships, block email, and trigger a transfer of ownership of files. This is critical for security.
⚙️ Automating ILM with MIM
Microsoft Identity Manager (MIM) is the primary on‑premises tool for ILM. It connects to HR systems (e.g., SAP, Workday) via connectors and automates the entire joiner‑mover‑leaver process. Typical workflow:
- HR system exports employee data (e.g., CSV, API) to a file or database.
- MIM imports the data, compares it with the metaverse, and determines what actions are needed.
- For a new employee, MIM creates a user in AD, sets attributes, and adds to default groups.
- For a role change, MIM updates group memberships (removing old, adding new).
- For a leaver, MIM disables the account and optionally moves it to a “Disabled Users” OU.
☁️ ILM in the Cloud
For hybrid environments, Azure AD Connect synchronises identities to the cloud. For ILM, you can use:
- Azure AD Connect with HR provisioning: Azure AD Connect can import from HR systems using the “HR-driven provisioning” feature (premium).
- Microsoft Identity Manager in hybrid: MIM can still manage on‑prem identities and sync to Azure AD.
- Azure AD entitlement management: Part of Azure AD Identity Governance, it automates access requests and assignments.
🛡️ Best Practices for ILM
- Source of truth: HR system should be the authoritative source for employee data.
- Attribute mapping: Define clear mapping between HR attributes (e.g., department code) and AD attributes (e.g., department name).
- Role‑based provisioning: Use role‑based access control (RBAC) – assign groups based on job code, not individually.
- Regular recertification: Periodically review user access (e.g., quarterly) to ensure it's still appropriate.
- Emergency procedures: Have a manual process for urgent joiner/leaver scenarios if automation fails.
- Auditing: Log all provisioning actions for compliance.
13.9 Integrating Third‑Party Identity Stores
🔗 Why Integrate with Third‑Party Stores?
Many organisations have identity data in multiple systems – HR systems (SAP, Workday, Oracle), databases, LDAP directories (e.g., OpenLDAP), or cloud applications. Integrating these with Active Directory (and Azure AD) is essential for a unified identity experience and automated lifecycle management.
🔄 Common Integration Scenarios
- HR systems: Automate user provisioning from HR to AD (joiner‑mover‑leaver).
- Other LDAP directories: Consolidate identities from multiple directories into a single AD forest (e.g., after an acquisition).
- Databases: Use data from databases to populate AD attributes or drive group membership.
- Cloud apps: Provision users from AD to SaaS apps via Azure AD (using SCIM).
🛠️ Tools for Integration
- Microsoft Identity Manager (MIM): The primary on‑premises tool for integrating with diverse data sources. MIM has connectors for:
- Active Directory
- LDAP directories
- SQL databases
- Web services (SOAP/REST)
- File-based sources (CSV, XML)
- SAP, Oracle, IBM, and many others (via connectors from Microsoft or partners).
- Azure AD Connect: Can synchronise from on‑prem AD to Azure AD, but does not directly connect to HR systems (use MIM or third‑party for that).
- Azure AD identity provisioning: For cloud HR systems (e.g., Workday, SuccessFactors), Azure AD has built‑in connectors to provision users directly to Azure AD and on‑prem AD (via agent).
- Third‑party integration tools: Tools like Okta, OneLogin, and others can also integrate with multiple identity stores.
⚙️ Example: Integrating SAP with AD using MIM
- Install the MIM SAP connector (from Microsoft or a partner).
- Configure the connector to connect to the SAP system (RFC, BAPI calls).
- Define import attributes (e.g., personnel number, name, department, cost centre).
- Define sync rules to map SAP attributes to AD attributes.
- Set up provisioning rules (e.g., create user if not exists, update if changed, disable if terminated).
- Run the sync cycle – MIM imports from SAP and exports to AD.
🔐 Security Considerations
- Secure the connection between MIM and third‑party systems (encryption, service accounts with least privilege).
- Protect the MIM server as a Tier 0 asset.
- Audit all changes made via integration.
- Validate data quality from third‑party systems before importing.
13.10 Identity Governance & Reporting
📊 What is Identity Governance?
Identity governance is the policies and processes that ensure the right people have the right access to the right resources at the right time. It includes access certifications, role management, and reporting. In hybrid environments, identity governance spans on‑premises AD and Azure AD.
🔑 Key Components of Identity Governance
- Access certifications (reviews): Regularly review user access to ensure it's still appropriate. Managers certify that their direct reports still need access to certain groups or applications.
- Role management: Define roles (e.g., Sales, Finance) and the access associated with them. Users are assigned roles, and access is granted automatically.
- Entitlement management: Allow users to request access (e.g., to a SharePoint site) with approval workflows.
- Reporting and analytics: Generate reports on user access, group memberships, privileged accounts, and compliance.
🛠️ Microsoft Tools for Identity Governance
- Azure AD Identity Governance: Part of Azure AD Premium P2. Includes:
- Entitlement management: Access packages, approval workflows, connected organisations.
- Access reviews: Schedule and manage reviews of group memberships, app assignments, and role assignments.
- Privileged Identity Management (PIM): JIT access and reviews for privileged roles.
- Terms of use: Require users to accept terms before accessing apps.
- Microsoft Identity Manager (MIM): On‑premises governance features like certification and role management.
- PowerShell and reporting tools: For custom reporting, you can use PowerShell to extract data from AD and Azure AD.
📋 Common Identity Governance Reports
- All users and their group memberships: Export to CSV for analysis.
- Inactive users: Users who haven't logged on for X days (potential stale accounts).
- Privileged group members: Members of Domain Admins, Enterprise Admins, etc.
- Service accounts with SPNs: Identify potential Kerberoasting targets.
- Users with multiple accounts: Potential duplicates.
- External users in Azure AD: Guest accounts and their access.
⚙️ Example: Setting up an Access Review in Azure AD
- In Azure AD, go to Identity Governance → Access reviews.
- Create a new access review for a group (e.g., “Sales Team”).
- Select reviewers (e.g., group owner, or selected reviewers).
- Set frequency (e.g., quarterly) and duration.
- Configure actions on completion (e.g., remove denied users automatically).
- Start the review. Reviewers get an email and can approve/deny access via the MyAccess portal.
- After the review period, results are applied (users denied are removed).
📈 Best Practices for Identity Governance
- Automate access reviews where possible (e.g., manager reviews for direct reports).
- Use role‑based access to simplify governance – manage roles, not individual permissions.
- Regularly review privileged group memberships (at least monthly).
- Generate and review reports on a schedule, not just ad‑hoc.
- Integrate governance tools with your SIEM for monitoring.
- Educate managers on their role in access certifications.
Identity governance ensures that access remains appropriate over time. It's not a one‑time project but an ongoing process. With tools like Azure AD Identity Governance and MIM, you can automate much of this, reducing risk and administrative burden.
🎓 Module 13 : Identity Management & PAM Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This module covered the full spectrum of identity management and privileged access – from MIM and PIM to tiered models, gMSAs, and identity governance. You are now equipped to design and operate a secure, compliant identity infrastructure.
Module 14 : Advanced Hybrid Identity & Azure AD Integration
This module provides a comprehensive deep dive into advanced hybrid identity concepts and the integration of on‑premises Active Directory with Azure Active Directory. You will explore the inner workings of Azure AD Connect, compare authentication methods (PHS, PTA, ADFS), learn about Azure AD Domain Services, implement Identity Protection and Conditional Access, plan cloud‑only migrations, understand Hybrid Kerberos Trust, troubleshoot sync issues, and secure hybrid environments. This module equips you with the expertise to design, implement, and manage complex hybrid identity solutions in real‑world enterprise scenarios.
14.1 Azure AD Connect Deep Dive
🔧 What is Azure AD Connect?
Azure AD Connect is Microsoft’s primary tool for synchronising on‑premises directories (Active Directory) with Azure Active Directory. It is the evolution of older tools (DirSync, Azure AD Sync) and provides a unified experience for hybrid identity. Azure AD Connect handles identity synchronisation, password hash sync, pass‑through authentication, federation configuration, and health monitoring.
Azure AD Connect is the bridge that keeps your on‑premises user database in sync with the cloud. When you create a user in AD, they automatically appear in Azure AD after sync.
⚙️ Azure AD Connect Components
- Synchronization Engine: The core component that performs identity synchronisation. It uses the Microsoft Identity Manager (MIM) sync engine.
- Metaverse: A staging database where identity information from connected directories (on‑prem AD) is consolidated before being exported to Azure AD.
- Connectors: Also called Management Agents (MAs), these handle communication with connected directories (AD, Azure AD).
- Azure AD Connect Health: A separate agent that provides monitoring and insights into the health of your sync server and AD FS farm.
- Password Synchronization component: Handles password hash sync.
- Pass‑Through Authentication agent: Installed on sync server or separate servers to handle PTA.
🔄 Sync Cycle – How It Works
- Import: The sync engine imports changes from on‑prem AD (Delta Import) and from Azure AD.
- Synchronize: Changes are processed in the metaverse. Rules determine how attributes map and which objects are provisioned.
- Export: Changes are exported to Azure AD (and optionally back to on‑prem AD for writeback features).
By default, sync runs every 30 minutes. You can force a sync with Start-ADSyncSyncCycle.
📋 Installation and Configuration Options
- Express Settings: For single AD forest with password hash sync. The simplest option.
- Custom Settings: Allows advanced configuration: filtering by OU, domain/forest selection, custom sync rules, federation, etc.
Key decisions during custom setup:
- Sign‑on method: Choose between Password Hash Sync (PHS), Pass‑Through Authentication (PTA), Federation with AD FS, or do not configure.
- User Principal Name (UPN) source: Which on‑prem attribute is used for Azure AD UPN (usually userPrincipalName).
- Source anchor: The attribute that uniquely identifies objects (default is
objectGUID). - OU filtering: Select which OUs to synchronise.
- Optional features: Password writeback, device writeback, group writeback, Exchange hybrid, etc.
🛠️ Staging Server and Disaster Recovery
It is recommended to deploy a staging server – a separate Azure AD Connect server that is configured in staging mode. This server imports the same sync configuration but does not export changes to Azure AD. It can be used to:
- Preview changes before applying them in production.
- Test configuration updates.
- Quickly take over if the primary server fails (by switching it to active mode).
📈 Azure AD Connect Health
Azure AD Connect Health provides monitoring and insights for your sync server and AD FS farm. It includes:
- Sync monitoring: Alerts for sync errors, performance metrics, object count.
- AD FS monitoring: Performance, sign‑in activity, security alerts.
- Email notifications: Get alerts on critical issues.
- Usage analytics: Reports on sign‑in activity and errors.
To enable Health, install the Health agent on your Azure AD Connect server and on AD FS servers.
🔐 Security Best Practices
- Protect the Azure AD Connect server as a Tier 0 asset.
- Use a dedicated service account for sync with least privilege.
- Enable MFA on the Azure AD global admin account used for sync.
- Regularly review sync logs for errors and unexpected changes.
- Keep Azure AD Connect updated to the latest version.
14.2 Seamless SSO & Pass‑Through Authentication
🔑 Seamless Single Sign‑On (Seamless SSO)
Seamless SSO automatically signs users in when they are on a corporate device connected to the corporate network. When enabled, users accessing cloud applications (e.g., Office 365) are not prompted for password – they are automatically authenticated using Kerberos. Seamless SSO works with both Password Hash Sync and Pass‑Through Authentication.
How it works:
- A special computer account named
AZUREADSSOis created in on‑prem AD. - The Kerberos decryption key for this account is securely shared with Azure AD.
- When a user accesses a cloud app from a domain‑joined device, Azure AD sends a challenge requesting Kerberos authentication.
- The client responds with a Kerberos ticket for the
AZUREADSSOaccount. - Azure AD validates the ticket (via a connection to on‑prem DCs) and issues an access token.
Requirements:
- Domain‑joined Windows client (Windows 7/8/10/11, Windows Server 2008 R2+).
- Client must be able to reach a domain controller (on‑prem).
- The
AZUREADSSOcomputer account must be created (done by Azure AD Connect). - Group Policy to add Azure AD URLs to Intranet zone (to allow Kerberos ticket delivery).
🔄 Pass‑Through Authentication (PTA)
Pass‑Through Authentication is an alternative to Password Hash Sync. With PTA, password validation happens on‑premises. The password hash never leaves the on‑prem environment, addressing security concerns for some organisations.
How PTA works:
- User attempts to sign in to Azure AD.
- Azure AD sends a request to a PTA agent (installed on‑prem) with the username and password (encrypted).
- The PTA agent validates the credentials against Active Directory using standard Windows APIs.
- The agent returns success/failure to Azure AD.
- Azure AD completes the sign‑in process.
PTA agents: You should install at least three PTA agents for high availability. They connect outbound to Azure AD (no inbound firewall rules needed).
🔁 Combining Seamless SSO with PTA
Seamless SSO and PTA work together: Seamless SSO provides the initial silent authentication (using Kerberos), and if that fails (e.g., client not domain‑joined), the user is prompted for password, which is validated via PTA.
⚙️ Enabling Seamless SSO and PTA
During Azure AD Connect installation:
- Select “Pass‑Through Authentication” as the sign‑on method.
- Check “Enable single sign‑on”.
Post‑installation:
# Enable Seamless SSO via PowerShell
Set-AADCloudSyncAuthentication -AuthenticationMethod Passthru -EnableSeamlessSso $true
🛡️ Security Considerations
- The
AZUREADSSOcomputer account password is managed by Azure AD Connect (rotated every 30 days). Treat it as a high‑value secret. - PTA agents have access to validate passwords; they should be secured and monitored.
- Use dedicated servers for PTA agents, not domain controllers, to reduce attack surface.
14.3 ADFS vs Password Hash Sync vs Pass‑Through Auth – Decision Guide
🔍 Choosing the Right Authentication Method
When implementing hybrid identity, one of the most critical decisions is the authentication method. Each has trade‑offs in complexity, security, and functionality. This section provides a detailed comparison to help you choose.
📊 Feature Comparison Table
| Feature | Password Hash Sync (PHS) | Pass‑Through Auth (PTA) | Federation (ADFS) |
|---|---|---|---|
| Password validation location | Azure AD | On‑premises AD | On‑premises AD FS / AD |
| Password hash stored in Azure AD? | Yes (hashed, salted) | No | No |
| Complexity | Low – easy to set up | Medium – requires agents | High – requires AD FS farm, certificates |
| User experience | Good, with Seamless SSO | Good, with Seamless SSO | Excellent, supports rich claims and smart cards |
| Offline authentication | Users can sign in if Azure AD is reachable (password cached) | Requires on‑prem connectivity (agents) | Requires on‑prem connectivity (AD FS) |
| Leaked credential detection | Yes (via Azure AD Identity Protection) | Yes (via agents) | Requires additional configuration |
| Support for smart cards | No | No | Yes |
| Support for on‑prem MFA | No | No | Yes (e.g., RSA SecurID) |
| Custom claims | Limited (can be added via sync rules) | Limited | Full claims transformation |
| High availability | Built‑in (Azure AD) | Requires multiple agents | Requires AD FS farm |
| Typical use cases | Most organisations; simple, secure | Organisations with “no hash in cloud” policies | Existing AD FS, smart card, complex claims |
📋 Decision Factors
- Security requirements: If storing password hashes in the cloud is prohibited, PTA or ADFS is required.
- Existing infrastructure: If you already have an AD FS farm, federation might be the easiest path.
- User experience: All three can provide SSO, but ADFS supports richer scenarios.
- Complexity tolerance: PHS is simplest; ADFS is most complex.
- Need for smart cards: Only ADFS supports smart card authentication.
- Cloud vs on‑prem outage: PHS works if Azure AD is up but on‑prem is down; PTA and ADFS require on‑prem availability.
🔄 Hybrid Approaches
You can combine methods. For example, you can enable PHS as a backup for PTA or ADFS. If the on‑prem PTA agents or AD FS farm become unavailable, Azure AD can fall back to PHS for authentication. This is a recommended high‑availability pattern.
🛡️ Security Considerations
- PHS: Passwords are hashed with MD4 (for NTLM) and then salted and hashed again. Azure AD never receives plaintext passwords. Enable leaked credential detection.
- PTA: Agents make outbound connections; no inbound ports needed. Protect agent servers.
- ADFS: Complex attack surface; must secure AD FS servers, WAP servers, and certificates.
14.4 Azure AD Domain Services (AADDS)
☁️ What is Azure AD Domain Services?
Azure AD Domain Services (AADDS) provides managed domain services such as domain join, Group Policy, LDAP, and Kerberos/NTLM authentication in the cloud. It is a fully managed service that synchronises identities from Azure AD (or from on‑prem AD via Azure AD Connect) to provide a traditional AD experience for cloud‑only or hybrid applications.
AADDS gives you a managed domain in Azure without needing to deploy and manage domain controllers. It's ideal for lifting and shifting legacy applications that require AD authentication to the cloud.
🔧 When to Use AADDS
- Lift‑and‑shift applications: Moving on‑prem apps that require AD authentication (e.g., file servers, SharePoint) to Azure VMs.
- Cloud‑only applications needing Kerberos/LDAP: Applications that cannot use modern authentication (OAuth/SAML).
- Development/test environments: Quickly create an AD environment without managing DCs.
When NOT to use AADDS: If you need full AD DS functionality (schema extensions, FSMO roles, complex Group Policy), deploy IaaS domain controllers instead.
⚙️ How AADDS Works
- You enable AADDS in your Azure subscription, selecting a virtual network and DNS domain name (e.g.,
aadds.contoso.com). - AADDS synchronises user and group objects from your Azure AD tenant (which may be synced from on‑prem via Azure AD Connect).
- Microsoft fully manages the domain controllers – you get two IP addresses for LDAP, Kerberos, etc.
- You can join Azure VMs in the same virtual network to the managed domain using those IPs.
- You can apply Group Policy to the managed domain (limited set of policies).
🔄 Synchronisation to AADDS
- From Azure AD: AADDS syncs users and groups from your Azure AD tenant. If you have Azure AD Connect, on‑prem users appear in Azure AD, then sync to AADDS.
- Password hashes: For NTLM and Kerberos authentication, AADDS needs password hashes. These must be synchronised from on‑prem AD (if hybrid) or from cloud‑only users (requires Azure AD to store hashes, which is default).
- Sync frequency: Changes in Azure AD are reflected in AADDS within a few minutes.
🔒 Security and Networking
- AADDS is deployed into a dedicated subnet in your virtual network. Network Security Groups (NSGs) must allow required ports (TCP 389, 636, 3268, 3269, 5986, etc.) from authorised sources.
- Use a VPN or ExpressRoute to connect on‑prem resources to the AADDS domain.
- AADDS supports secure LDAP (LDAPS) with custom certificates.
📋 Limitations
- No schema extensions – you cannot add custom attributes.
- Limited Group Policy – only a subset of settings.
- No support for customising the domain (e.g., no OUs beyond the default).
- No FSMO roles – everything is managed by Microsoft.
- Not suitable for domain controllers in a multi‑domain forest.
14.5 Identity Protection & Risk Events
🛡️ What is Azure AD Identity Protection?
Azure AD Identity Protection is a feature of Azure AD Premium P2 that provides a consolidated view of risk events and potential vulnerabilities affecting your organisation's identities. It uses machine learning to detect suspicious activities and allows you to configure risk‑based conditional access policies.
Identity Protection acts like a security camera for your user accounts. It watches for unusual behaviour – like a login from a strange location or a leaked password – and alerts you or automatically blocks access.
📊 Types of Risk Events
Identity Protection detects two main categories of risk:
- User risk: Probability that a user's identity has been compromised. Factors include leaked credentials, suspicious activity, etc.
- Sign‑in risk: Probability that a specific sign‑in attempt is not legitimate. Factors include anonymous IP address, atypical travel, unfamiliar location, etc.
Common risk event types:
- Leaked credentials (username/password found on dark web).
- Sign‑ins from anonymous IP addresses (e.g., Tor).
- Sign‑ins from atypical locations (impossible travel).
- Sign‑ins from unfamiliar locations.
- Sign‑ins from infected devices.
- Sign‑ins from IP addresses with suspicious activity.
- Password spray attacks.
⚙️ Configuring Identity Protection
- Enable Identity Protection: Requires Azure AD Premium P2 licenses for all users.
- Review risk events: In the Azure portal, navigate to “Identity Protection” → “Risk events” to see detections.
- Configure user risk policy: Create a policy that automatically remediates user risk (e.g., require password change, block access).
- Configure sign‑in risk policy: Create a policy that reacts to sign‑in risk (e.g., require MFA, block access).
- Investigate and remediate: Review risky users and sign‑ins, confirm compromised or safe, and take action.
🔁 Risk Remediation
- Self‑remediation: Users can complete MFA or change password to clear risk.
- Administrator remediation: Admin can dismiss risk, confirm user compromised, or require password reset.
📈 Integration with Conditional Access
Identity Protection risk signals can be used in Conditional Access policies. For example:
- If sign‑in risk is medium or high, require MFA.
- If user risk is high, block sign‑in and require admin to reset password.
This creates a dynamic, risk‑based security posture.
🛡️ Best Practices
- Enable both user risk and sign‑in risk policies.
- Set risk level thresholds appropriately (e.g., treat medium and high as actionable).
- Regularly review risk events and investigate anomalies.
- Integrate Identity Protection with your SIEM for centralised monitoring.
- Educate users on MFA and self‑service password reset.
14.6 Conditional Access Policies
🔐 What is Conditional Access?
Conditional Access is the policy‑based access control engine in Azure AD. It evaluates signals (user, device, location, risk, application) and applies policies to allow or block access. Conditional Access is the core of Zero Trust security in Microsoft 365 and Azure.
Conditional Access is like a bouncer at a club – they check your ID (user), where you're from (location), what you're wearing (device compliance), and if you're on a guest list (risk), then decide whether to let you in.
🧩 Components of a Conditional Access Policy
- Assignments:
- Users and groups: Who the policy applies to (include/exclude).
- Cloud apps or actions: Which applications (e.g., Office 365, custom apps) or user actions (e.g., register security info) are targeted.
- Conditions: Sign‑in risk, device platforms, locations, client apps, etc.
- Access controls:
- Grant: Require MFA, require compliant device, require hybrid Azure AD joined device, require approved client app, etc. You can require multiple controls (AND/OR).
- Session: Control session behaviour (e.g., sign‑in frequency, persistent browser session, app‑enforced restrictions).
- Enable policy: Report‑only, On, or Off.
📋 Common Conditional Access Policies
- Require MFA for admins: All administrative roles must use MFA.
- Require MFA for all users: For high‑security environments.
- Block legacy authentication: Block protocols that don't support MFA (e.g., POP, IMAP, older Office clients).
- Require compliant device for access to corporate apps: Only allow access from Intune‑compliant devices.
- Risk‑based policies: Integrate with Identity Protection to require MFA or block based on risk.
- Location‑based access: Block access from untrusted countries or require MFA from specific locations.
⚙️ Creating a Conditional Access Policy
Example: Require MFA for all users accessing Office 365.
- In Azure AD, go to “Security” → “Conditional Access” → “New policy”.
- Name the policy “Require MFA for Office 365”.
- Under “Assignments” → “Users”, select “All users”.
- Under “Cloud apps”, select “Office 365”.
- Under “Conditions”, optionally configure exclusions (e.g., trusted locations).
- Under “Access controls” → “Grant”, select “Require multi‑factor authentication”.
- Set “Enable policy” to “Report‑only” initially, then “On”.
🔄 Policy Evaluation and Reporting
- Report‑only mode: Test policies without impacting users. Logs are available in the “Conditional Access Insights” workbook.
- What If tool: Simulate policies to see what would apply to a user under specific conditions.
- Sign‑in logs: Show which policies were applied and whether access was granted or blocked.
🛡️ Best Practices
- Start with report‑only mode to understand impact.
- Create exclusion groups for break‑glass accounts.
- Use “Require MFA” for all admins as a baseline.
- Block legacy authentication – it's a common attack vector.
- Combine with Intune compliance policies for device‑based access.
- Regularly review policy effectiveness using the Conditional Access insights workbook.
14.7 Migrating to Azure AD (Cloud‑Only Identity)
☁️ The Journey to Cloud‑Only
Many organisations are considering moving from a hybrid identity model to a cloud‑only identity model, where all users and groups are managed directly in Azure AD and no on‑premises Active Directory is used. This simplifies management, reduces costs, and enables modern identity features. However, it's a significant undertaking that requires careful planning.
Cloud‑only eliminates on‑prem dependencies, reduces attack surface, and enables full use of Azure AD features like Microsoft Entra Identity Governance, PIM, and Conditional Access without sync complexity.
📋 Pre‑Migration Assessment
- Inventory on‑prem dependencies: Identify all applications and services that require on‑prem AD. These may include:
- LDAP‑authenticated applications.
- Kerberos‑based applications.
- File servers with NTFS permissions based on AD groups.
- Print servers.
- On‑premises Exchange.
- Plan for remediation: For each dependency, determine a cloud‑ready alternative or migration path.
- Assess user impact: Will users need new passwords? How will they access resources?
🔄 Migration Strategies
- Phased migration: Move users and applications in waves. This is less risky but takes longer.
- Big bang migration: All users and applications move at once. Riskier but faster.
- Hybrid to cloud‑only: Gradually reduce dependency on on‑prem AD until it can be decommissioned.
⚙️ Key Migration Steps
- Clean up on‑prem AD: Remove stale accounts, groups, and outdated data.
- Migrate file and print services: Move file servers to SharePoint Online/OneDrive or Azure Files. Use Azure AD authentication where possible.
- Migrate applications:
- For apps that support modern auth (SAML/OAuth), configure SSO with Azure AD.
- For legacy apps, consider using Azure AD Application Proxy or deploying them on Azure IaaS and integrating with AADDS.
- Migrate user identities:
- If you have Azure AD Connect, you can gradually stop sync and manage users directly in Azure AD.
- Use PowerShell or Microsoft Graph to create/update users in Azure AD.
- Reset user passwords and communicate the change.
- Decommission on‑prem AD: After verifying all dependencies are moved, gracefully demote domain controllers and decommission servers.
🔑 Managing Passwords After Migration
- Cloud‑only users use their Azure AD password. Enable self‑service password reset (SSPR) to reduce helpdesk calls.
- If you have Microsoft 365, passwords can be synchronised if you use Azure AD Connect, but for cloud‑only, you manage them in the cloud.
🛡️ Security Considerations
- Implement strong Conditional Access policies (MFA, risk‑based policies).
- Enable Identity Protection and PIM for privileged roles.
- Regularly review guest access and external collaboration.
- Ensure you have break‑glass accounts in Azure AD.
14.8 Hybrid Kerberos Trust (Azure AD Kerberos for on‑prem resources)
🔁 What is Hybrid Kerberos Trust?
Hybrid Kerberos Trust (also known as Azure AD Kerberos for on‑prem resources) allows cloud‑provisioned users (in Azure AD) to access on‑premises resources that require Kerberos authentication. It creates a trust between Azure AD and on‑prem AD, enabling Azure AD users to get Kerberos tickets for on‑prem services.
Normally, cloud‑only users can't access file servers or other Kerberos‑based resources. Hybrid Kerberos Trust bridges that gap, allowing them to seamlessly authenticate to on‑prem apps using Kerberos.
⚙️ How It Works
- You create a Kerberos server object in on‑prem AD representing Azure AD.
- Azure AD is configured to trust this object.
- When an Azure AD user needs access to an on‑prem resource, they request a Kerberos ticket from Azure AD.
- Azure AD issues a partial ticket, which the client uses to request a full ticket from an on‑prem domain controller.
- The client presents the ticket to the on‑prem service (e.g., file server), which grants access.
This is similar to how Seamless SSO works, but it's for cloud‑only users, not on‑prem synced users.
📋 Requirements
- Azure AD Premium P1 or P2 licenses.
- Hybrid infrastructure – you need connectivity between Azure AD and on‑prem AD (via Azure AD Connect or a domain controller).
- On‑prem AD domain functional level must be Windows Server 2008 R2 or later.
🛠️ Enabling Hybrid Kerberos Trust
Using Azure AD Connect:
- In Azure AD Connect, enable “Kerberos authentication for on‑premises resources” during installation or by running the configuration wizard again.
- Provide enterprise admin credentials to create the Kerberos server object in on‑prem AD.
- Complete the configuration.
Using PowerShell:
# On an on‑prem DC, create the Kerberos server object
New-AzureADKerberosServer -Domain "contoso.com" -CloudCredential (Get-Credential) -KeyCredential (New-Object ...)
🔐 Security Considerations
- The Kerberos server object in on‑prem AD is a high‑value target – protect it like a domain controller.
- Monitor for any changes to this object.
- Use Conditional Access to control which Azure AD users can access on‑prem resources.
📊 Use Cases
- Cloud‑only employees need access to on‑prem file shares.
- Legacy applications that require Windows Integrated Authentication.
- Gradual migration where some users are cloud‑only but resources remain on‑prem.
14.9 Troubleshooting Azure AD Connect
🔍 Common Issues and Resolutions
Azure AD Connect is generally reliable, but issues can arise due to network problems, permission changes, or object conflicts. This section covers common problems and how to resolve them.
📋 Common Sync Errors and Fixes
| Error / Symptom | Possible Cause | Fix |
|---|---|---|
| “Stopped‑Server” / sync not running | Azure AD Connect service not started, network issue, database corruption | Restart service, check connectivity, run a full import/sync, restore from staging server |
| “Duplicate attribute” (e.g., ProxyAddresses, UserPrincipalName) | Two objects in on‑prem AD have the same value for a unique attribute | Find and resolve duplicate in AD (remove or modify one) |
| “Object sync skipped” due to authoritative source | An object is not in scope for sync (filtered out) or connector space rules prevent export | Check OU filtering, sync scope, and connector filters |
| “Azure AD role membership not synced” | User assigned Azure AD role in cloud, but not synced back (Azure AD roles are not synced from on‑prem) | Manage Azure AD roles directly in Azure AD (or use PIM) |
| “Password writeback failing” | Permissions issue on on‑prem AD, or Azure AD Connect not updated | Check that password writeback is enabled, ensure service account has reset password rights, check firewall |
| “Large object” sync failure | Attribute value exceeds Azure AD size limit (e.g., thumbnailPhoto too large) | Resize the attribute in on‑prem AD (or exclude from sync) |
🛠️ Troubleshooting Tools
- Synchronization Service Manager: Located on the Azure AD Connect server. Provides detailed view of connector spaces, metaverse, and sync cycles. Allows you to see objects that failed to sync and error details.
- PowerShell: Use
Get-ADSyncScheduler,Start-ADSyncSyncCycle, andGet-ADSyncConnectorRunto manage and troubleshoot. - Azure AD Connect Health: Provides monitoring and alerts for sync issues.
- Event Viewer: Look for Application and Directory Service events.
- Network connectivity tests: Use
Test-NetConnectionto verify connectivity to Azure AD endpoints (e.g.,*.msappproxy.net).
🔍 Step‑by‑Step Troubleshooting Process
- Check scheduler status: Run
Get-ADSyncSchedulerto ensure sync is enabled and scheduled. - Review recent sync history: In Synchronization Service Manager, check “Operations” tab for any failed runs.
- Examine connector space: For a user not syncing, search in the connector space and look for errors in “Pending Export” or “Failed” status.
- Check metaverse object: See if the object is present in the metaverse and has correct attribute mappings.
- Review sync rules: Verify that the correct sync rules are applied (inbound and outbound).
- Check Azure AD audit logs: Look for sync‑related events in Azure AD.
📊 Resolving Duplicate Attribute Errors
Duplicate errors (e.g., “Another object with the same value for attribute ProxyAddresses already exists”) are common. To resolve:
- Identify the conflicting object in on‑prem AD using the error details (ObjectId).
- Modify the attribute value on one of the objects (e.g., change proxyAddress).
- Run a delta sync to push the change to Azure AD.
- If the object in Azure AD already exists, you may need to remove it and re‑sync (careful with existing mailboxes).
🔄 Forcing a Full Sync
Sometimes a full import and sync is needed after configuration changes:
Start-ADSyncSyncCycle -PolicyType Initial
14.10 Hybrid Identity Security & Incident Response
🛡️ Securing the Hybrid Identity Bridge
In a hybrid identity environment, the connection between on‑prem and cloud is a critical security boundary. Attackers target Azure AD Connect servers, PTA agents, AD FS farms, and sync accounts. A comprehensive security strategy must protect both sides.
🔐 Key Security Controls
- Protect Azure AD Connect server: Treat it as Tier 0. Use PAW for administration, enable MFA, apply security baselines, and restrict network access.
- Secure sync service account: Use a dedicated account with least privilege. Rotate password regularly. Never reuse for other services.
- Monitor sync activity: Alert on unexpected changes to sync configuration, connector spaces, or metaverse. Use Azure AD Connect Health.
- Secure PTA agents: Run on dedicated servers (not DCs). Use outbound only connectivity. Monitor agent health.
- Secure AD FS: Use WAP servers, regular certificate rotation, and monitor AD FS logs for anomalies.
- Enable audit logging: For both on‑prem and cloud, enable detailed logging and forward to a SIEM.
🚨 Incident Response for Hybrid Identity
In case of a security incident (e.g., compromised sync server, Golden Ticket attack, Azure AD admin account compromise), follow a structured response.
- Detection: Identify through alerts (e.g., abnormal sync, suspicious logons).
- Containment:
- Disable the compromised account(s).
- Isolate the affected server(s) from network.
- If sync server compromised, stop sync service and switch to staging server.
- Eradication:
- Reset passwords for all accounts that may have been exposed (especially service accounts).
- Rotate the
AZUREADSSOaccount password if compromised. - Rebuild compromised servers from clean backup.
- Check for backdoors (e.g., unexpected Azure AD guest accounts, modified sync rules).
- Recovery:
- Restore sync from staging server.
- Re‑enable sync and monitor for recurrence.
- Communicate with affected users.
- Lessons Learned:
- Review incident to identify root cause.
- Update security controls and monitoring.
- Conduct Purple Team exercise to test improvements.
📋 Key Event IDs to Monitor in Hybrid Environment
- On‑prem AD: 4720 (user created), 4728 (group member added), 4740 (lockout), 5136 (directory changes).
- Azure AD Connect: Check Health alerts, sync failure events in Application log.
- Azure AD: Sign‑in logs (especially for admins), audit logs for role changes, Conditional Access failures.
- PTA agents: Event logs for authentication failures.
- AD FS: 501 (token issuance), 302 (authentication failures).
🔄 Periodic Security Reviews
- Quarterly review of Azure AD Connect configuration and staging server.
- Review PTA agent health and version.
- Audit Azure AD administrative roles and PIM activations.
- Run tools like IdFix to detect duplicate or problematic attributes before they cause sync issues.
- Perform a hybrid security assessment using tools like Azure AD Assessment (in Microsoft 365 Defender).
Hybrid identity is the gateway to both on‑prem and cloud resources. A comprehensive security strategy, combined with a well‑practiced incident response plan, is essential to protect this critical infrastructure.
🎓 Module 14 : Advanced Hybrid Identity Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This module covered the most advanced concepts in hybrid identity – from deep dive into Azure AD Connect to security and incident response. You are now equipped to design, implement, and secure complex hybrid identity solutions.
Module 15 : Active Directory Certificate Services (AD CS) – PKI Deep Dive
This module provides a comprehensive deep dive into Active Directory Certificate Services (AD CS), Microsoft's Public Key Infrastructure (PKI) solution. You will learn about PKI components, enterprise vs standalone CAs, certificate templates, attack vectors (ESC1‑ESC8), hardening techniques, autoenrollment, key archival, integration scenarios (802.1x, RDP), CA migration, and CRL/OCSP configuration. AD CS is a powerful but often misconfigured service; this module equips you to design, deploy, and secure a robust PKI.
15.1 PKI Components in Active Directory Certificate Services
🔐 What is AD CS?
Active Directory Certificate Services (AD CS) is Microsoft’s server role that provides customizable services for issuing and managing public key certificates. It is used to create a Public Key Infrastructure (PKI) that supports secure communication, authentication, and encryption across your organization. AD CS integrates with Active Directory Domain Services (AD DS) to provide certificate‑based identity for users, computers, and services.
AD CS is like a digital ID card printer for your organization. It issues certificates that can be used for logging in (smart cards), securing websites (SSL/TLS), encrypting files (EFS), and more.
🧩 Key Components of AD CS
- Certification Authority (CA): The server that issues and manages certificates. CAs can be root (top of hierarchy) or subordinate (intermediate/issuing).
- CA Web Enrollment: A web interface that allows users to request certificates via a browser (optional).
- Online Responder (OCSP): Provides Online Certificate Status Protocol responses for real‑time certificate revocation checking.
- Network Device Enrollment Service (NDES): Enables routers, switches, and other network devices to obtain certificates (using SCEP).
- Certificate Enrollment Web Service / Policy Web Service: Allow certificate enrollment for computers outside the domain (e.g., internet clients).
- Certificate Templates: Blueprints that define the properties of certificates a CA can issue (e.g., purpose, validity, issuance requirements).
- Certificate Authority Web Enrollment: Deprecated but still present for legacy support.
📊 PKI Hierarchy
A typical PKI hierarchy consists of:
- Root CA: The trust anchor. It issues certificates only to subordinate CAs. Highly secured, often offline.
- Subordinate (Issuing) CAs: Issue certificates to end‑users, computers, and devices. They are online and have a certificate issued by the root.
This two‑tier hierarchy protects the root CA from compromise. If an issuing CA is compromised, the root can revoke its certificate and issue a new one.
🔒 AD CS and Active Directory Integration
Enterprise CAs integrate with AD DS to:
- Publish certificates and CRLs (Certificate Revocation Lists) to AD.
- Use AD for authentication and authorization during certificate requests.
- Support autoenrollment based on group policies.
- Store certificate templates in AD (CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration).
🛡️ Security Considerations
- The Root CA is the most critical asset – it should be offline and stored securely.
- Protect CA private keys using Hardware Security Modules (HSMs) or strong software protection.
- Limit access to CA management to a small, highly trusted group.
- Enable auditing on CAs to track certificate issuance.
15.2 Enterprise CA vs Standalone CA
🏢 Enterprise CA
An Enterprise CA is integrated with Active Directory and requires AD DS. It uses certificate templates to control issuance and automatically publishes certificates to AD. Enterprise CAs are ideal for internal use where all clients are domain‑joined.
Key features:
- Uses AD for authentication – requesters must have a domain account.
- Supports certificate templates – administrators define templates with specific issuance policies.
- Autoenrollment – users and computers can automatically receive certificates based on Group Policy.
- Publishes certificates and CRLs to AD, making them accessible to all domain members.
- Can issue smart card certificates and EFS certificates.
💻 Standalone CA
A Standalone CA does not require Active Directory. It can be used in workgroup environments or for external CAs. It does not use certificate templates; instead, administrators configure issuance manually. All requests are placed in a pending queue and must be approved by a CA administrator.
Key features:
- No dependency on AD – can be used in isolated networks.
- No certificate templates – all request attributes are specified in the request itself.
- Manual approval – all requests are pending until an administrator issues them.
- Does not publish certificates to AD (but can publish to file).
- Suitable for root CAs (often offline) or for issuing certificates to external entities.
📋 Comparison Table
| Feature | Enterprise CA | Standalone CA |
|---|---|---|
| AD dependency | Yes, requires AD DS | No |
| Certificate templates | Yes | No |
| Request authentication | Kerberos/NTLM | None – request only |
| Request processing | Automatic (if permissions allow) | Pending queue, manual approval |
| Certificate publication | To AD | To file or not published |
| Use cases | Internal PKI, domain‑joined clients, autoenrollment | Offline root CA, external entities, test environments |
🏛️ Typical Deployment
In a secure enterprise PKI, you often combine both:
- Offline Standalone Root CA: Kept offline, used only to issue certificates for subordinate CAs.
- Online Enterprise Subordinate CA(s): Issue certificates to users and computers using templates and autoenrollment.
15.3 Certificate Templates (V2 and V3)
📜 What are Certificate Templates?
Certificate templates are blueprints that define the properties and issuance requirements for certificates issued by an Enterprise CA. They are stored in Active Directory and can be configured with a wide range of settings. Templates are versioned – V2 (introduced in Windows 2000/2003) and V3 (introduced in Windows Server 2008 R2).
📋 Template Properties
- General: Template name, validity period, renewal period.
- Request Handling: Allow private key export, renew with same key, use of alternate subject name.
- Subject Name: How the subject is built – from AD (common name, UPN, email) or supplied in request.
- Extensions: Key usages (digital signature, key encipherment, etc.), application policies (EKU – Extended Key Usage).
- Security: Which users/groups have permissions to enroll, autoenroll, or read the template.
- Issuance Requirements: CA certificate manager approval, number of authorized signatures.
🔄 V2 vs V3 Templates
- V2 Templates: The classic format, supported by all versions of Windows Server with AD CS. They are editable but have some limitations (e.g., no support for issuance policies in the template itself).
- V3 Templates: Introduced in Windows Server 2008 R2. They support newer features like:
- Cryptography Next Generation (CNG) keys.
- Support for suite B algorithms.
- More granular issuance policies.
- Better integration with newer Windows versions.
When you upgrade a CA to a newer version, you can create V3 templates, but existing V2 templates remain functional. You can also duplicate a V2 template to create a V3 version.
⚙️ Common Built‑in Templates
- Administrator: For code signing, smart card logon, etc.
- Domain Controller: Used by domain controllers for LDAP over SSL, Kerberos authentication.
- Web Server: For IIS servers (server authentication).
- User: Standard user certificates (EFS, client authentication).
- Smartcard Logon: For smart card authentication.
- Workstation: For computer authentication (802.1x).
🔒 Template Security Best Practices
- Only grant “Enroll” permissions to users/groups that absolutely need certificates.
- Use “Autoenroll” for computers and users where appropriate (e.g., domain controllers).
- For sensitive templates (e.g., domain controller, smart card logon), require “CA certificate manager approval”.
- Disable “Allow private key to be exported” unless absolutely necessary.
- Set appropriate validity periods (shorter for user certificates, longer for CA certificates).
- Review templates regularly for misconfigurations that could lead to attacks (ESC1‑ESC8).
15.4 AD CS Attack Vectors (ESC1‑ESC8)
⚠️ Understanding the Risks
In 2021, researchers at SpecterOps published a landmark whitepaper titled “Certified Pre‑Owned” detailing eight common misconfigurations in Active Directory Certificate Services that allow attackers to escalate privileges and compromise domains. These are known as ESC1‑ESC8. Understanding these attack vectors is critical for hardening your PKI.
📋 ESC1 – Misconfigured Certificate Templates
Attack: A template allows low‑privileged users to request a certificate with a Subject Alternative Name (SAN) that can be set to any value (e.g., “Administrator”). The template also has “Enrollee Supplies Subject” enabled and allows client authentication.
Impact: Attacker requests a certificate as “Administrator” and uses it to authenticate to any service (e.g., via PKINIT for Kerberos).
Mitigation: Disable “Enrollee Supplies Subject” for templates that grant authentication. Require CA manager approval. Audit templates with client authentication EKU.
📋 ESC2 – Misconfigured Template with Any Purpose
Attack: A template has the “Any Purpose” EKU (2.5.29.37.0) or no EKU. This allows the certificate to be used for any purpose, including authentication.
Impact: Similar to ESC1, attacker can request a certificate and use it for authentication.
Mitigation: Avoid “Any Purpose” templates. Define specific EKUs.
📋 ESC3 – Misconfigured Enrollment Agent Templates
Attack: An enrollment agent template is misconfigured, allowing an attacker to request a certificate on behalf of another user. The enrollment agent certificate can then be used to request other certificates.
Mitigation: Strictly control enrollment agent permissions. Require CA approval.
📋 ESC4 – Access Control Vulnerabilities on Templates
Attack: A low‑privileged user has write permissions on a certificate template (e.g., “Full Control”). They can modify the template to enable dangerous settings (like ESC1) and then request a certificate.
Mitigation: Audit permissions on all templates. Only allow Domain Admins and CA Admins to modify templates.
📋 ESC5 – Weak CA Security
Attack: Permissions on the CA itself are misconfigured (e.g., a low‑privileged user has “Manage CA” or “Manage Certificates”). They can issue certificates directly.
Mitigation: Restrict CA management to a small group. Use dedicated CA admin accounts.
📋 ESC6 – EDITF_ATTRIBUTESUBJECTALTNAME2
Attack: The CA has the “EDITF_ATTRIBUTESUBJECTALTNAME2” flag set. This allows any requester (even without template permissions) to specify a SAN in the certificate request.
Impact: Any user can request a certificate with any SAN, including Domain Admin.
Mitigation: Disable this flag. Check with certutil -getreg policy\EditFlags.
📋 ESC7 – Vulnerable CA Web Interface
Attack: The CA Web Enrollment interface is enabled and misconfigured. Attackers can use it to request certificates without authentication (if NTLM is disabled) or to bypass restrictions.
Mitigation: Disable the web interface if not needed. Require HTTPS and Extended Protection for Authentication.
📋 ESC8 – NTLM Relay to CA Web Enrollment
Attack: An attacker coerces a domain controller or other server to authenticate to the attacker’s machine using NTLM (e.g., via PetitPotam). The attacker then relays that authentication to the CA web enrollment endpoint to obtain a certificate for the server (e.g., a domain controller certificate). The certificate can then be used to perform DCSync.
Mitigation: Disable NTLM on the CA server. Enable Extended Protection for Authentication. Use HTTPS with channel binding. Disable the web enrollment interface if not required.
🛡️ General Mitigations
- Use the PSPKIAudit or Certify tools to scan for misconfigurations.
- Disable any certificate templates that are not needed.
- Set strong permissions on templates and the CA.
- Require CA manager approval for sensitive templates.
- Disable the web enrollment interface unless absolutely necessary.
- Enable auditing and monitor for unusual certificate requests.
- Treat the CA servers as Tier 0 assets.
15.5 Hardening AD CS
🛡️ Comprehensive Hardening Guide
Hardening AD CS involves securing the CA servers, the certificate templates, and the communication channels. This section consolidates best practices to protect your PKI from attack.
1. Secure the CA Servers (Tier 0)
- Treat all CA servers (especially issuing CAs) as Tier 0 assets – same protection as domain controllers.
- Install CAs on dedicated servers (not domain controllers).
- Use Hardware Security Modules (HSMs) for private key protection, especially for root CAs.
- Apply security baselines (e.g., Microsoft Security Compliance Toolkit).
- Enable BitLocker on CA server drives.
- Restrict network access – only necessary ports (RPC, SMB for admin, LDAP for enrollment).
- Use PAWs for CA administration.
2. Harden Certificate Templates
- Remove dangerous EKUs (e.g., Any Purpose) from templates.
- Disable “Enrollee Supplies Subject” unless absolutely required (and then require CA approval).
- Set “CA certificate manager approval” on templates that grant authentication.
- Restrict enrollment permissions to only necessary groups.
- Disable “Allow private key export” unless required (and then require approval).
- Use appropriate validity periods (e.g., 1‑2 years for user certs, 5‑10 years for CA certs).
3. Secure the CA Configuration
- Disable the “EDITF_ATTRIBUTESUBJECTALTNAME2” flag. Check with:
certutil -getreg policy\EditFlags
To disable:certutil -setreg policy\EditFlags -EDITF_ATTRIBUTESUBJECTALTNAME2 - Disable NTLM authentication on the CA (use Kerberos only).
- Enable Extended Protection for Authentication (EPA) on the CA web enrollment (if used).
- Set strong key protection – require a password for CA private key access.
- Regularly back up the CA database and private keys.
4. Disable Unnecessary Services
- Disable CA Web Enrollment (IIS) if not used. This eliminates ESC8 and other web‑based attacks.
- Disable NDES if not required.
- If web enrollment is needed, enforce HTTPS with strong TLS configuration, and enable EPA.
5. Auditing and Monitoring
- Enable auditing on the CA: In the CA console, right‑click CA → Properties → Auditing. Enable all events (certificate issuance, revocation, etc.).
- Monitor Event ID 4886 (certificate issued), 4887 (certificate request failed), 4898 (template loaded).
- Forward these events to a SIEM.
- Alert on any certificate issued for a sensitive template (e.g., Domain Controller) from an unexpected requester.
6. Regular Assessments
- Run tools like PSPKIAudit or Certify to scan for misconfigurations.
- Conduct periodic reviews of certificate templates and permissions.
- Test incident response for CA compromise.
15.6 Certificate Autoenrollment & Smart Cards
🔄 What is Autoenrollment?
Autoenrollment is a feature that allows domain‑joined users and computers to automatically request and renew certificates without user intervention. It is configured through Group Policy and is essential for large‑scale certificate deployment (e.g., smart cards, computer certificates for 802.1x).
⚙️ Configuring Autoenrollment
Steps:
- Create and configure a certificate template with the appropriate EKUs and security permissions. Ensure the template has “Autoenroll” permission for the desired groups (e.g., Domain Users).
- Publish the template on the issuing CA (right‑click Certificate Templates → New → Certificate Template to Issue).
- Configure Group Policy for autoenrollment:
- Navigate to Computer Configuration → Policies → Windows Settings → Security Settings → Public Key Policies.
- For user certificates, configure “Certificate Services Client – Auto‑Enrollment” in User Configuration.
- Set the policy to “Enabled”, with “Renew expired certificates, update pending certificates, and remove revoked certificates” and “Update certificates that use certificate templates”.
- Apply the GPO to the appropriate OUs.
💳 Smart Card Enrollment
Smart cards require certificates for user authentication. AD CS supports two main smart card enrollment methods:
- Smart Card Enrollment Station: An administrator uses a smart card reader and a dedicated workstation to issue smart cards to users. This is common for high‑security environments.
- Self‑service enrollment: Users can enroll for a smart card certificate via the web enrollment interface or using the
certreqcommand. Requires the appropriate template and permissions.
Smart card template requirements:
- Template must include “Smart Card Logon” EKU (1.3.6.1.4.1.311.20.2.2).
- Subject name should be built from AD (usually UPN).
- Key size: RSA 2048 or greater.
- Validity period should align with smart card lifecycle.
🔑 Using Smart Cards for Logon
Once a smart card certificate is issued, users can log on to Windows with the smart card (requires a reader and PIN). To enable, configure Group Policy:
- Computer Configuration → Policies → Windows Settings → Security Settings → Local Policies → Security Options: Set “Interactive logon: Require smart card” to “Enabled” for specific users/groups.
- Alternatively, configure user accounts to “Smart card is required for interactive logon” in ADUC.
📋 Best Practices
- Use autoenrollment for computer certificates (e.g., for 802.1x).
- For smart cards, use a two‑factor approach: card + PIN.
- Store smart card private keys on the card (cannot be exported).
- Regularly audit issued smart card certificates.
15.7 Key Archival & Recovery
🔐 What is Key Archival?
Key archival is the process of storing a user’s private key (encrypted) on the CA server. This allows the CA to recover the key if it is lost (e.g., user reinstalls OS, smart card damaged). Key archival is typically used for certificates that support data recovery, such as EFS (Encrypting File System) certificates.
⚙️ Configuring Key Archival
Prerequisites:
- The CA must be configured to support key archival. This requires a Key Recovery Agent (KRA) certificate.
- The certificate template must have “Archive subject’s encryption private key” enabled.
Steps:
- Create a Key Recovery Agent certificate template (built‑in template “Key Recovery Agent”).
- Enroll a KRA certificate for a designated recovery agent (can be a user or service account).
- On the CA, add the KRA certificate:
certutil -setreg ca\KRAFlags +KRAF_ENABLE
Then import the KRA certificate:certutil -repairstore my "KRA_Cert_Hash" - In the certificate template (e.g., “EFS Recovery Agent”), enable “Archive subject’s encryption private key”.
- Publish the template.
🔑 Key Recovery Process
When a user loses their private key, an administrator can recover it using the KRA certificate.
- On the CA, use the Certificate Authority console or
certutil -getkeyto retrieve the archived key. - The key is encrypted with the KRA certificate. The recovery agent (holding the KRA private key) can decrypt it.
- The recovered key can be provided to the user (e.g., as a PFX file).
🛡️ Security Considerations
- Protect the KRA certificate and private key extremely well – it can decrypt all archived keys.
- Use a hardware security module (HSM) for KRA keys if possible.
- Enable key archival only for specific templates where recovery is business‑critical (e.g., EFS).
- Audit all key recovery operations.
- Consider using data recovery agents (DRA) instead of full key archival for EFS.
15.8 Integrating AD CS with 802.1x, RDP, and Other Services
🌐 802.1x Network Authentication
AD CS can issue certificates to computers and users for 802.1x network authentication (wired and wireless). This provides strong, certificate‑based authentication to network switches and wireless controllers.
Steps:
- Create a certificate template for “Computer” with “Client Authentication” EKU. Also, a template for “User” with “Client Authentication” EKU if user‑based authentication is used.
- Publish the templates and configure autoenrollment for computers (and optionally users).
- On the Network Policy Server (NPS) or RADIUS server, configure policies to require certificate‑based authentication.
- Configure the network devices (switches, WLAN controllers) to use EAP‑TLS (Extensible Authentication Protocol‑Transport Layer Security) with the CA trust chain.
🖥️ Remote Desktop (RDP) with Smart Cards or Certificates
AD CS can issue certificates for RDP server authentication (to verify the server’s identity) and for client authentication (smart card logon).
- RDP server certificates: Use a template with “Server Authentication” EKU. Install the certificate on the Remote Desktop Gateway (RD Gateway) or individual RDP hosts. Clients will trust the certificate if the CA is in their trusted root store.
- RDP client certificates (smart card): Users with smart card certificates can log on to RDP sessions if the server supports smart card authentication.
📧 Secure Email (S/MIME)
AD CS can issue certificates for email signing and encryption (S/MIME). Use the “User” or “Exchange User” templates with “Secure Email” EKU. Users can then configure their email client (Outlook) to use the certificate.
🔏 IPSec
AD CS can issue certificates for IPSec authentication. Computer certificates with “IPSec” EKU allow computers to authenticate to each other when establishing IPSec tunnels.
📜 Code Signing
Developers can use certificates issued by AD CS to sign code (scripts, executables). Use a template with “Code Signing” EKU. Ensure the CA is trusted by the target systems.
📋 Best Practices for Integration
- Use separate templates for different purposes (don't reuse a template for multiple EKUs unless necessary).
- Secure the CA chain – ensure all clients trust the root CA.
- Distribute the CA certificate and CRL via Group Policy or autoenrollment.
- Monitor certificate expiration for critical services (e.g., RDP servers).
15.9 Migrating a CA to New Hardware
🔄 Why Migrate?
Over time, you may need to move a CA to new hardware (e.g., server refresh, virtualisation) or upgrade the OS. Proper migration preserves the CA’s identity, issued certificates, and trust relationships.
📋 Migration Approaches
- Side‑by‑side migration: Install a new CA with the same name, then restore the CA database and keys. This is the preferred method.
- In‑place upgrade: Upgrade the OS on the existing CA server. Riskier but simpler. Only recommended for test environments.
⚙️ Side‑by‑Side Migration Steps
- Back up the existing CA:
- Back up the CA database and private key using
certutil -backupor the CA console. - Ensure you have the CA certificate and private key (PFX file) with the password.
- Back up the CA database and private key using
- Note current CA settings:
- Validity period, hash algorithm, key length.
- Certificate templates published.
- Extensions and registry settings (use
certutil -getreg).
- Install new server:
- Install the same Windows Server OS (or newer, but ensure compatibility).
- Install AD CS role with same CA name and key length.
- During installation, choose “Use existing private key” and import the backed‑up private key.
- Restore the CA database:
- Stop the CA service.
- Copy the backed‑up database files to the new server’s database folder (default:
%SystemRoot%\System32\CertLog). - Use
certutil -restoreif you used that method.
- Re‑publish templates:
- In the CA console, ensure all previously published templates are re‑published.
- Update CRL distribution points:
- If the CA name changed (it shouldn't), update all CRL URLs.
- Ensure the new CA can publish CRLs to the same locations (share permissions).
- Verify functionality:
- Request a test certificate.
- Check that the CRL is published correctly.
- Ensure autoenrollment still works.
- Decommission old CA:
- Uninstall AD CS role and shut down the old server.
🛡️ Important Considerations
- CA name must remain the same. Changing the name would break issued certificates (subject name embedded).
- Protect the private key during transfer. Use secure storage and delete temporary copies.
- Update DNS records if the new server has a different IP.
- Test thoroughly in a staging environment first.
15.10 CRL & OCSP Configuration
📜 What is a Certificate Revocation List (CRL)?
A CRL is a list of certificates that have been revoked by the CA before their expiration date. Clients check the CRL to ensure a certificate is still valid. AD CS publishes CRLs at regular intervals.
⚙️ Configuring CRL Distribution Points (CDPs)
CRL distribution points are URLs (HTTP, LDAP, file) where clients can retrieve the CRL. These are embedded in issued certificates. To configure:
- In the CA console, right‑click the CA → Properties → Extensions tab.
- Select “CRL Distribution Point (CDP)”.
- Add URLs where the CRL will be published. Common options:
ldap:///CN=<CATruncatedName>,<CDPContainer>?certificateRevocationList?base?objectClass=cRLDistributionPoint(publishes to AD).http://pki.contoso.com/crl/<ServerName>.crl(web server).file://\\server\share\<ServerName>.crl(network share).
- Ensure the CA has write permissions to the publication locations.
- Set the publication interval (e.g., weekly for full CRL, daily for delta CRL).
🌐 Online Certificate Status Protocol (OCSP)
OCSP provides real‑time revocation status. It is more efficient than downloading large CRLs. AD CS includes the Online Responder role for OCSP.
Configuring OCSP:
- Install the Online Responder role on a server.
- In the Online Responder console, add a new Revocation Configuration.
- Select the CA and specify the signing certificate (a certificate for the responder).
- Configure the responder to retrieve CRL from the CA (or from a local copy).
- Add the OCSP URL to the CA’s Authority Information Access (AIA) extension.
- Update CA certificate templates to include the OCSP URL in the AIA extension.
📋 CRL vs OCSP
| Feature | CRL | OCSP |
|---|---|---|
| Bandwidth | Higher – clients download entire list | Lower – single response per certificate |
| Freshness | Depends on publication interval (can be hours/days stale) | Real‑time (if responder is online) |
| Privacy | Client does not reveal which certificate it's checking | Client reveals certificate serial number |
| Complexity | Simple to set up | More complex (requires OCSP responder) |
🛡️ Best Practices
- Publish CRLs to multiple locations (HTTP for internet clients, LDAP for domain clients).
- Use delta CRLs to reduce download size.
- Ensure CRL URLs are accessible by all clients (firewall rules).
- Monitor CRL publication for failures.
- For high‑security environments, use OCSP with stapling (OCSP stapling) to improve privacy.
🎓 Module 15 : AD Certificate Services (PKI) Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This module covered the full spectrum of Active Directory Certificate Services – from components and templates to attack vectors, hardening, and integration. You are now equipped to design, deploy, and secure a PKI that meets enterprise needs.
Module 16 : Enterprise Architecture & Governance for Active Directory
This module provides a comprehensive deep dive into the architectural and governance aspects of designing, managing, and securing Active Directory at an enterprise scale. You will learn how to design forest and domain structures for mergers and acquisitions, apply naming best practices, implement delegation and role‑based access control, plan disaster recovery, meet regulatory compliance (PCI, HIPAA), perform capacity planning, virtualize domain controllers, manage time synchronization, decommission legacy AD, and establish documentation and change management processes. These topics are essential for senior architects and engineers responsible for the long‑term health and governance of AD.
16.1 Forest & Domain Design for Mergers and Acquisitions (M&A)
🏢 The Challenge of M&A
Mergers and acquisitions present one of the most complex challenges for Active Directory architects. You are faced with integrating disparate identity systems, each with its own forest structure, domains, trust relationships, and security policies. The goal is to create a unified identity environment that enables collaboration, reduces complexity, and maintains security.
Imagine two companies with their own separate AD forests merging. You need to decide whether to keep them separate (with trusts), merge them into one forest, or create a new forest and migrate users. Each choice has trade‑offs.
📋 Key Decision Factors
- Business drivers: Is the merger a full integration, or will companies operate independently? Need for collaboration (email, file sharing) vs. separation.
- Security requirements: Do both companies trust each other's security practices? Regulatory requirements for data isolation.
- Existing infrastructure: Number of domains, functional levels, applications tied to specific domains.
- Timeline and resources: How quickly must integration happen? Available budget and personnel.
🔀 Integration Models
- Model 1: Forest Trust (Federated)
- Establish a two‑way forest trust between the two forests.
- Users in Forest A can access resources in Forest B (and vice versa) with appropriate permissions.
- No identity consolidation; each company retains its own AD.
- Pros: Fast, low‑risk, minimal changes.
- Cons: Two forests to manage, no single identity, may complicate compliance.
- Best for: Short‑term integration, or when companies will remain separate.
- Model 2: Domain Consolidation
- Migrate users and resources from the acquired company's domain into the parent company's domain.
- Use Active Directory Migration Tool (ADMT) or third‑party tools.
- Pros: Single forest/domain, simplified management, unified identity.
- Cons: Time‑consuming, complex, requires careful planning and testing.
- Best for: Full integration where the acquired company will be absorbed.
- Model 3: New Forest Creation
- Create a brand new forest for the merged entity. Migrate users from both legacy forests into the new forest.
- Pros: Clean slate, consistent design, no legacy baggage.
- Cons: Most complex and time‑consuming; requires migrating all users and resources.
- Best for: Truly new entity, or when both legacy forests are problematic.
📊 M&A Integration Checklist
- Discovery: Inventory users, groups, computers, and applications in both environments.
- UPN and namespace planning: Decide on a common UPN suffix (e.g., @newcompany.com).
- Trust planning: If using forest trust, plan trust direction, authentication scope (selective vs domain‑wide).
- SID history: If migrating, preserve SID history for resource access.
- Exchange integration: If using Exchange, plan mailbox moves and coexistence.
- Application testing: Test all critical applications after integration.
- Security review: Assess new trust relationships for security risks.
🛡️ Security Considerations
- Forest trusts are transitive – any compromised domain in one forest could affect the other.
- Use selective authentication to limit which users can access resources.
- Audit trust relationships regularly.
- Consider using a separate “bastion” forest for privileged access.
16.2 Active Directory Naming Best Practices
🔤 The Importance of Good Naming
Consistent and well‑planned naming conventions for domains, OUs, groups, and users are essential for manageability, troubleshooting, and compliance. Poor naming leads to confusion, errors, and security gaps.
Naming is like labelling boxes in a warehouse. If you label them clearly and consistently, you can always find what you need. If not, you waste time and might lose things.
🌐 Domain Naming
- Use a subdomain of your public DNS name (e.g.,
ad.contoso.com,corp.contoso.com). Avoid using the public root domain (contoso.com) directly to prevent DNS conflicts. - For child domains, use geographic or functional names:
emea.ad.contoso.com,asia.ad.contoso.com. - Keep domain names short enough for NetBIOS (pre‑Windows 2000) names (max 15 characters). The NetBIOS name should be an abbreviation (e.g.,
CONTOSO). - Avoid spaces, underscores, or special characters.
📁 OU Naming and Structure
- Use a consistent hierarchy. Common models:
- Geographic: Region → Country → City → Department
- Functional: Department → Role
- Hybrid: Often the best – top‑level by location, then by function.
- OU names should be descriptive but concise: “Sales Users”, “IT Computers”, “Service Accounts”.
- Avoid deep nesting (more than 4‑5 levels) to simplify Group Policy and delegation.
- Consider using a “Resources” OU for servers, “Workstations” for clients, “Users” for user accounts, “Groups” for groups.
Example:
contoso.com (domain)
├── Users
│ ├── Sales
│ ├── IT
│ └── Finance
├── Computers
│ ├── Workstations
│ │ ├── Sales
│ │ ├── IT
│ │ └── Finance
│ └── Servers
├── Groups
│ ├── Security
│ └── Distribution
└── Service Accounts
👥 User and Group Naming
- User logon names (sAMAccountName): Use a consistent format, e.g., first.last, firstinitial.lastname, or employee ID. Ensure uniqueness across the domain.
- User Principal Name (UPN): Should match the user's email address (e.g.,
user@contoso.com) for consistency. - Group names: Use a prefix to indicate scope and purpose. For example:
G_Sales_Users– Global group for Sales usersDL_Sales_Share_Read– Domain Local group for read access to Sales shareU_All_Employees– Universal groupAPP_SAP_Admins– Application‑specific group
🖥️ Computer Naming
- Include location, role, and sequential number: e.g.,
NYC-SRV-FS01(New York, Server, File Server 01),LON-WKS-1001(London Workstation). - Limit NetBIOS names to 15 characters.
- Avoid using special characters.
📋 Best Practices Summary
- Document your naming convention and enforce it via training and scripts.
- Use standard abbreviations (NYC, LON, SRV, WKS, APP).
- Plan for future growth – leave room in numbering schemes.
- Review and update naming conventions periodically.
16.3 Delegation & Role‑Based Access Control (RBAC)
🔑 The Principle of Least Privilege in Practice
Delegation is the process of granting specific administrative permissions to users or groups without making them members of highly privileged groups like Domain Admins. Combined with Role‑Based Access Control (RBAC), it ensures that administrators have only the permissions necessary for their job. This section expands on concepts introduced in Module 6 with a focus on enterprise‑scale delegation.
Instead of giving the helpdesk the keys to the entire kingdom (Domain Admin), you give them a key to only the user accounts (reset passwords) and maybe a key to the printer room (manage printers). That's delegation.
🧩 Designing a Delegation Model
- Identify administrative roles: List all tasks that need delegation. Common roles:
- Helpdesk (reset passwords, unlock accounts)
- User Administrators (create/modify users and groups)
- Server Administrators (manage computer objects for servers)
- Workstation Administrators (manage workstations)
- Group Administrators (manage group memberships for specific groups)
- Map roles to OUs: Which OUs contain the objects each role needs to manage? For example, helpdesk may need access to all user OUs, but server admins only need access to server OUs.
- Create security groups for roles: For each role, create a global or universal security group (e.g., “Role_Helpdesk”, “Role_ServerAdmins”).
- Delegate permissions at the OU level: Use the Delegation of Control Wizard to grant the group appropriate permissions on the target OUs. Common delegated tasks:
- Reset user passwords and force password change at next logon.
- Create, delete, and manage user accounts.
- Modify group membership.
- Join computers to the domain (delegated at the domain level).
🛠️ Advanced Delegation with Custom Permissions
The Delegation of Control Wizard covers common tasks, but sometimes you need finer control. Use the Security tab (Advanced Features) to set custom permissions on OUs or objects. For example:
- Grant “Write” permission on the “telephoneNumber” attribute for helpdesk to update phone numbers.
- Grant “Create” and “Delete” computer objects in a specific OU for server admins.
- Grant “Read” permission on all objects for auditors.
PowerShell example for custom delegation:
# Grant "Reset Password" extended right to a group on a specific OU
$ou = "OU=Sales,DC=contoso,DC=com"
$group = "CONTOSO\Role_Helpdesk"
$acl = Get-Acl "AD:$ou"
$identity = [System.Security.Principal.NTAccount]$group
$adRights = [System.DirectoryServices.ActiveDirectoryRights] "ExtendedRight"
$type = [System.Security.AccessControl.AccessControlType] "Allow"
$inheritance = [System.DirectoryServices.ActiveDirectorySecurityInheritance] "All"
$guid = [System.Guid]"00299570-246d-11d0-a768-00aa006e0529" # GUID for Reset Password
$rule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule($identity, $adRights, $type, $guid, $inheritance)
$acl.AddAccessRule($rule)
Set-Acl -Path "AD:$ou" -AclObject $acl
📋 RBAC with Group Nesting (AGDLP)
Use the AGDLP model to manage permissions efficiently:
- A – User accounts are placed into Global groups based on role (e.g., “G_Sales_Users”).
- G – Global groups are placed into Domain Local groups that represent permissions (e.g., “DL_Sales_Share_Write”).
- DL – Domain Local groups are assigned permissions on resources.
- P – Permissions are granted to the Domain Local groups.
For delegation, you can also use this model: create Global groups for delegations (e.g., “G_Helpdesk”), and assign them to delegated permissions on OUs. This simplifies reporting and changes.
🔄 Auditing Delegation
- Regularly review delegated permissions using tools like AD ACL Scanner or PowerShell.
- Enable auditing on sensitive OUs to track changes made by delegated users.
- Monitor Event IDs 5136 (modifications) and 5141 (deletions) for delegated OUs.
📊 Example Delegation Matrix
| Role | Group | Permissions | Scope (OUs) |
|---|---|---|---|
| Helpdesk | Role_Helpdesk | Reset password, unlock accounts | All User OUs |
| User Admin | Role_UserAdmin | Create/modify users and groups | Specific department OUs (Sales, IT) |
| Server Admin | Role_ServerAdmin | Manage computer objects (servers) | Servers OU |
| Workstation Admin | Role_WSAdmin | Manage computer objects (workstations) | Workstations OUs |
16.4 Disaster Recovery Planning for Active Directory
🚨 The Importance of AD Disaster Recovery
Active Directory is the identity backbone of your organisation. If AD is lost, access to all resources is lost. A disaster recovery (DR) plan for AD must be comprehensive, tested regularly, and integrated with your overall business continuity plan.
📋 DR Plan Components
- Recovery Time Objective (RTO): How quickly must AD be restored? (e.g., 4 hours)
- Recovery Point Objective (RPO): How much data loss is acceptable? (e.g., 24 hours)
- Inventory: Document all domain controllers, their roles (FSMO, GC), sites, and backup locations.
- Backup strategy: Regular system state backups of at least one DC per domain. Store backups offsite (or in the cloud).
- Restore procedures: Document step‑by‑step for:
- Non‑authoritative restore (single DC failure).
- Authoritative restore (accidental deletion).
- Full forest recovery (all DCs lost).
- Communication plan: Who to contact, how to communicate during an outage.
🔄 Recovery Scenarios
- Single DC failure: If you have other DCs, simply promote a new DC. No restore needed.
- Single DC failure with no other DC in the domain: Perform a non‑authoritative restore from backup, or install a new DC with the same name (may require metadata cleanup).
- Accidental deletion of objects (user, OU): Use Active Directory Recycle Bin (if enabled) or perform an authoritative restore.
- All DCs in a domain lost: Restore one DC from backup (non‑authoritative), then promote additional DCs. This is the most complex scenario.
- Forest recovery (all domains lost): Extremely rare but must be planned. Requires restoring one DC per domain from backup, in the correct order (root domain first).
💾 Backup Best Practices
- Back up system state (includes AD database, SYSVOL, registry) of at least one DC per domain daily.
- Use multiple backup methods: Windows Server Backup, third‑party tools (Veeam, Commvault), and cloud backups.
- Store backups in a secure, offsite location.
- Test restores regularly (quarterly). Document the test results.
- Ensure backups are protected from ransomware – use immutable storage or offline copies.
📊 Sample Forest Recovery Procedure
- Ensure the root domain DC is restored first. Install a new server with same name, restore system state, and perform a non‑authoritative restore.
- Verify the restored DC can start AD DS and is healthy.
- Restore one DC per child domain (if any) using the same process.
- After all DCs are restored, force replication and verify.
- Seize FSMO roles if necessary.
- Promote additional DCs as needed.
- Update DNS records and ensure clients can locate DCs.
🧪 Testing the DR Plan
- Conduct tabletop exercises annually.
- Perform a full recovery test in an isolated lab at least once a year.
- Document lessons learned and update the plan.
16.5 Active Directory in Regulated Industries (PCI, HIPAA, GDPR)
🔐 Compliance Requirements and AD
Organisations in regulated industries must meet specific security and audit requirements. Active Directory plays a central role in identity and access management, and its configuration directly impacts compliance with standards like PCI DSS, HIPAA, and GDPR.
Compliance frameworks require you to prove that you have control over who can access what, and that you log and monitor access. AD is where these controls are implemented.
📋 PCI DSS (Payment Card Industry Data Security Standard)
Relevant requirements:
- Requirement 7: Restrict access to cardholder data by business need‑to‑know. Implement RBAC.
- Requirement 8: Identify and authenticate access to system components.
- Unique IDs for each user.
- Strong password policies (length, complexity, history).
- Two‑factor authentication for remote access.
- Lockout after failed attempts.
- Requirement 10: Track and monitor all access to system components. Enable auditing for user activity.
- Requirement 2: Change vendor defaults – rename default Administrator account.
AD implementation:
- Implement Fine‑Grained Password Policies for different user groups.
- Enable and forward security logs (Event IDs 4624, 4625, 4728, etc.) to a SIEM.
- Rename built‑in Administrator account via GPO.
- Use RBAC and delegation to enforce least privilege.
🏥 HIPAA (Health Insurance Portability and Accountability Act)
Relevant requirements:
- Security Rule – Access Control: Implement technical policies to allow access only to authorised persons.
- Audit Controls: Record and examine activity in systems containing ePHI.
- Integrity: Protect ePHI from improper alteration or destruction.
- Person or Entity Authentication: Verify that a person seeking access is who they claim.
AD implementation:
- Use smart cards or multi‑factor authentication for access to ePHI.
- Enable detailed auditing on file servers and AD.
- Implement Group Policies to enforce encryption (e.g., BitLocker, EFS).
- Regularly review user access and group memberships.
🇪🇺 GDPR (General Data Protection Regulation)
Relevant requirements:
- Right to erasure (“right to be forgotten”): Ability to delete personal data.
- Data protection by design and default: Implement appropriate technical measures.
- Security of processing: Ensure confidentiality, integrity, and availability.
- Records of processing activities: Document processing activities.
AD implementation:
- Develop a process to delete user accounts and associated data when requested.
- Enable auditing to track access to personal data.
- Implement strong access controls and MFA.
- Maintain documentation of AD structure, delegation, and policies.
📊 Common Controls Across Frameworks
| Control | PCI | HIPAA | GDPR |
|---|---|---|---|
| Unique user IDs | ✔ | ✔ | ✔ |
| Strong password policy | ✔ | ✔ | ✔ |
| Multi‑factor authentication | ✔ | ✔ | Recommended |
| Audit logging | ✔ | ✔ | ✔ |
| Least privilege (RBAC) | ✔ | ✔ | ✔ |
| Regular access reviews | ✔ | ✔ | ✔ |
| Data deletion process | ✔ (cardholder data) | ✔ | ✔ |
16.6 Capacity Planning for Domain Controllers
📈 Why Capacity Planning Matters
Properly sizing domain controllers ensures they can handle authentication loads, replication traffic, and directory searches without performance degradation. Under‑provisioned DCs lead to slow logons, failed requests, and user frustration. Over‑provisioning wastes resources.
Capacity planning is like making sure your restaurant kitchen has enough stoves and chefs to handle the dinner rush. Too few, and customers wait. Too many, and you waste money.
📊 Factors Affecting DC Performance
- Number of users and computers: More objects mean larger database and more authentication traffic.
- Authentication rate: Logons, Kerberos ticket requests, NTLM authentications per second.
- Group Policy processing: Complex GPOs and scripts increase load.
- Replication traffic: Number of DCs, change frequency, site link speeds.
- LDAP queries: Applications searching AD (Exchange, custom apps).
- Global Catalog usage: GC servers handle more queries and replication.
📏 Sizing Guidelines
Microsoft provides general guidelines based on user count and scenario. These are starting points; you should monitor and adjust.
| User Count | vCPUs | RAM | Disk (IOPS) | Network |
|---|---|---|---|---|
| Up to 1,000 | 2 | 4‑6 GB | 50‑100 IOPS | 1 Gbps |
| 1,000 – 5,000 | 4 | 8‑12 GB | 100‑300 IOPS | 1 Gbps |
| 5,000 – 25,000 | 8 | 16‑24 GB | 300‑600 IOPS | 1‑10 Gbps |
| 25,000 – 100,000+ | 16+ | 32‑64 GB+ | 1000+ IOPS | 10 Gbps |
Note: These are estimates. Always monitor actual performance and adjust.
💾 Disk Considerations
- Place the AD database (NTDS.DIT) and logs on separate drives (or at least separate virtual disks) for performance.
- Use high‑performance storage (SSD) for DCs, especially for logs.
- Monitor disk latency – should be < 10 ms for logs, < 20 ms for database.
📈 Monitoring Performance
Key performance counters to monitor on DCs:
- Processor\% Processor Time: Overall CPU usage. Should be below 80%.
- Memory\Available MBytes: Available RAM. Should be at least a few hundred MB.
- LogicalDisk(*)\Avg. Disk sec/Read and Write: Disk latency.
- NTDS\DRA Inbound Bytes Compressed (and Uncompressed): Replication traffic.
- NTDS\LDAP Searches/sec: LDAP query load.
- NTDS\Kerberos Authentications/sec: Authentication load.
🔄 Scaling Out
- Add more DCs to distribute load, especially in large sites.
- Use Global Catalog servers wisely – every DC can be a GC, but this increases replication. Balance with query needs.
- Consider using RODCs in branch offices to offload authentication.
📋 Capacity Planning Process
- Baseline current performance using monitoring tools.
- Forecast growth (user count, new applications).
- Use sizing guidelines to estimate requirements.
- Test in a lab if possible.
- Provision new DCs or upgrade existing ones.
- Monitor and adjust.
16.7 Virtualizing Domain Controllers – Best Practices
☁️ Virtualization Benefits and Risks
Virtualizing domain controllers (DCs) offers flexibility, cost savings, and easier disaster recovery. However, it also introduces new risks, such as time synchronization issues, snapshot pitfalls, and resource contention. This section covers best practices for running DCs on virtualization platforms (Hyper‑V, VMware, etc.).
⏱️ Time Synchronization
The most common issue with virtual DCs is time drift. Domain controllers must have accurate time for Kerberos to work. Virtualization hosts often provide time synchronization to guests, but DCs should never sync time from the host. They must sync from the domain hierarchy (PDC emulator).
Best practice:
- Disable time synchronization between the host and the guest DC. In Hyper‑V, uncheck “Time synchronization” in integration services. In VMware, disable “Time synchronization” in VM options.
- Ensure the guest DC is configured to sync time from the domain hierarchy (default).
📸 Snapshots – The USN Rollback Danger
Never use virtual machine snapshots on a domain controller. Restoring a snapshot reverts the DC to a previous state, causing its USN to roll back. When the DC replicates, it will reintroduce old data, leading to USN rollback – a critical forest issue that may require rebuilding DCs.
Alternative: Use application‑consistent backups (e.g., VSS‑aware backups) instead of snapshots. If you must use snapshots for testing, ensure the DC is disconnected from the network and never allowed to replicate.
🔄 Generation IDs (VM‑GENID)
Starting with Windows Server 2012 and Windows 8, virtual DCs support VM‑Generation ID. This feature allows the DC to detect when it has been restored from a snapshot. When a snapshot restore is detected, the DC resets its USN and initiates a non‑authoritative sync, preventing USN rollback. This requires:
- Windows Server 2012 or later on the DC.
- Hyper‑V (or VMware with VM‑GenID support).
- No guarantee with older snapshots – still best to avoid snapshots.
📊 Resource Allocation
- Do not over‑commit resources (CPU, memory) for DCs. They are critical and should have guaranteed resources.
- Use static memory allocation (not dynamic) for DCs.
- Place DCs on separate hosts or clusters to avoid single points of failure.
- Use high‑performance storage (SSD) for DC virtual disks.
🛡️ Anti‑Affinity Rules
In a cluster, configure anti‑affinity rules to ensure DCs are not running on the same physical host. This prevents a host failure from taking down multiple DCs simultaneously.
📋 Other Best Practices
- Do not virtualize the PDC emulator on a host that is prone to high load or frequent reboots.
- Ensure the virtual network is reliable and has sufficient bandwidth.
- Monitor virtualization hosts for resource contention that could affect DC performance.
- Use separate virtual disks for OS, AD database, and logs.
- Enable Write‑Through caching for disk controllers (if applicable) to improve performance.
16.8 Time Synchronization & Kerberos – Deep Dive
⏰ The Critical Role of Time
Kerberos authentication relies on timestamps to prevent replay attacks. The default maximum time skew between a client and a domain controller is 5 minutes. If clocks differ by more than this, authentication fails. Therefore, accurate time synchronization across all domain members is not optional – it is a prerequisite.
Kerberos tickets have timestamps. If the client's clock is too far off from the DC's clock, the ticket looks like it's from the past or future and is rejected. Time sync keeps everyone on the same page.
📊 Windows Time Service Hierarchy
Windows uses a hierarchical time synchronization model:
- Forest root PDC emulator: The authoritative time source for the entire forest. It should be configured to sync with an external reliable time source (e.g., a hardware clock, NIST, pool.ntp.org).
- Other domain controllers: Sync with the forest root PDC (or with other DCs in the same site). By default, they use the domain hierarchy.
- Domain members (servers and workstations): Sync with any DC in their domain (usually the one that authenticated them).
⚙️ Configuring the PDC Emulator
To configure the PDC emulator to sync with an external NTP source:
# On the PDC emulator, run as administrator
w32tm /config /manualpeerlist:"0.pool.ntp.org 1.pool.ntp.org" /syncfromflags:manual /reliable:yes /update
net stop w32time && net start w32time
w32tm /resync
For higher accuracy, use more specific NTP servers (e.g., time.windows.com, time.nist.gov). You can also use Group Policy to configure time settings across all DCs.
🔍 Troubleshooting Time Sync
Common commands:
w32tm /query /status– Show current time source and offset.w32tm /query /peers– List configured NTP peers.w32tm /monitor– Check time against domain controllers.w32tm /resync– Force a resynchronization.
If you see errors, check that the time service is running, firewall ports (UDP 123 for NTP) are open, and the external source is reachable.
⚠️ Common Time Sync Issues
- Time drift on virtualised DCs: As covered in 16.7, disable host‑guest time sync.
- Firewall blocking NTP: Ensure UDP 123 is allowed outbound from the PDC.
- Misconfigured hierarchy: Some DCs might be pointed to external sources directly, breaking the hierarchy. Use Group Policy to enforce sync from the PDC.
- Hyper‑V TimeSync service: Ensure it's disabled for DCs.
📅 Group Policy for Time Sync
You can configure all client machines to use the domain hierarchy by default. No extra config is needed. However, you can enforce settings via Computer Configuration → Administrative Templates → System → Windows Time Service.
🔒 Security Considerations
- NTP is not authenticated by default. In high‑security environments, consider using authenticated NTP (with certificates) or use a hardware appliance.
- Prevent unauthorized time changes by restricting who can change system time (local policy).
16.9 Decommissioning Legacy Active Directory
🗑️ The Need for Decommissioning
Over time, you may need to decommission old domain controllers, domains, or even entire forests. This could be due to hardware refresh, migration to new hardware/cloud, or consolidation after an acquisition. Proper decommissioning is essential to avoid orphaned objects, replication errors, and security risks.
🔄 Decommissioning a Domain Controller
Graceful demotion (preferred):
- Ensure the DC is not holding any FSMO roles. Transfer roles if necessary.
- Ensure the DC is not a Global Catalog server (if others exist, you can demote; otherwise, transfer GC role).
- Use Server Manager or PowerShell to remove the AD DS role. This will demote the DC.
- After demotion, the server is a workgroup machine. You can then shut it down.
PowerShell demotion:
Uninstall-ADDSDomainController -DemoteOperationMasterRole -Force
Forceful removal (if DC is unreachable):
- If the DC is offline and cannot be brought online, you must perform metadata cleanup to remove its references from AD.
- Use
ntdsutilor ADSI Edit to remove the DC object and its associated objects (NTDS Settings, etc.).
ntdsutil metadata cleanup steps:
ntdsutil
metadata cleanup
connections
connect to server DC01 # a working DC
quit
select operation target
list domains
select domain 0 # select appropriate domain
list sites
select site 0 # select site containing the DC
list servers in site
select server 0 # select the DC to remove
quit
remove selected server # confirm
quit
quit
🗺️ Decommissioning a Domain
To remove an entire domain from a forest:
- Ensure all DCs in the domain are demoted or removed.
- Remove all trusts to other domains.
- Use
ntdsutilto remove the domain from the forest. This updates the configuration partition. - Manually remove DNS records associated with the domain.
🌲 Decommissioning a Forest
This is rare but may be needed after a full migration. Steps:
- Demote all DCs in all domains.
- Ensure all trusts are removed.
- Use
ntdsutilto remove the forest from the configuration (advanced, usually not needed). - Shut down all servers.
🧹 Post‑Decommissioning Cleanup
- Remove DNS records (A, SRV) associated with the decommissioned DC.
- Remove any references in scripts, configuration files, or monitoring tools.
- Update documentation.
📋 Checklist for Decommissioning
- Verify no FSMO roles remain on the DC.
- Verify no applications or services depend on the DC.
- Transfer or remove Global Catalog role.
- Ensure replication is healthy before demotion.
- Back up the DC before demotion (just in case).
- After demotion, perform metadata cleanup if needed.
- Update DNS and documentation.
16.10 Documentation & Change Management for Active Directory
📚 The Importance of Documentation
Active Directory is a complex, critical infrastructure. Without accurate and up‑to‑date documentation, troubleshooting becomes guesswork, audits fail, and knowledge is lost when staff leave. Comprehensive documentation is a hallmark of a mature IT organisation.
Documentation is the instruction manual for your AD. It tells you what you have, how it's configured, and why. Without it, you're flying blind.
📋 What to Document
- Forest and domain information:
- Forest name, domain names, functional levels.
- FSMO role holders and their locations.
- Schema version and any custom extensions.
- Trust relationships (direction, type, authentication).
- Site topology:
- Site names, associated subnets.
- Site links (names, costs, schedules, sites included).
- Bridgehead servers (preferred or automatic).
- Replication schedules and intervals.
- Domain controllers:
- Server name, location (physical/virtual), site.
- IP addresses, OS version, AD DS version.
- Roles (GC, FSMO, RODC).
- Backup status and schedule.
- Key hardware specs (CPU, RAM, disk).
- OU structure:
- Diagram of OU hierarchy.
- Purpose of each OU.
- Delegation permissions on each OU (which groups have what rights).
- Group Policy:
- List of all GPOs, with links and purposes.
- Summary of key settings in each GPO.
- WMI filters and their queries.
- Security filtering and delegation.
- Security groups:
- Privileged groups (Domain Admins, etc.) and their members.
- Key security groups for RBAC (e.g., Role_Helpdesk).
- Group nesting relationships.
- Service accounts:
- List of service accounts (including gMSAs).
- Purpose, permissions, password management (manual/gMSA).
- Backup and DR procedures:
- Step‑by‑step restore procedures (authoritative, non‑authoritative).
- Contact information for key personnel.
- Location of backups and recovery tools.
🛠️ Tools for Documentation
- Manual documentation: Wiki (Confluence, SharePoint), Word documents, Excel spreadsheets.
- Automated documentation tools:
- ADInfo (Netwrix): Generates reports on AD configuration.
- PingCastle: Provides health and security reports that can serve as documentation.
- PowerShell scripts: Use
Get-AD*cmdlets to export configuration to CSV or HTML. - Microsoft 365 Admin Center / Azure AD: For hybrid components.
🔄 Change Management
Change management is the process of controlling changes to your AD infrastructure. It ensures that changes are planned, tested, reviewed, and documented. A formal change management process reduces the risk of errors and outages.
Key elements of a change management process:
- Request for Change (RFC): Formal description of the proposed change, including reason, impact, and rollback plan.
- Review and approval: Change advisory board (CAB) reviews the change, assesses risk, and approves or rejects.
- Implementation: Change is implemented according to the plan, during a maintenance window if needed.
- Testing: Verify the change works as intended and does not cause issues.
- Documentation: Update documentation to reflect the change.
- Post‑implementation review: Evaluate the change and learn from any issues.
📋 Example Change Management Checklist for AD
- Change description and justification.
- Impact analysis (which users/systems affected).
- Risk assessment (low/medium/high).
- Implementation plan (step‑by‑step).
- Rollback plan (how to revert).
- Testing plan (how to verify).
- Communication plan (who to notify).
- Approvals (CAB, management).
- Post‑implementation verification.
📈 Continuous Improvement
- Review documentation and change management processes annually.
- Conduct periodic audits to ensure documentation matches reality.
- Use lessons learned from incidents to improve processes.
Documentation and change management are the foundation of a well‑governed Active Directory. They may seem tedious, but they save time, prevent errors, and are essential for compliance and business continuity. Invest in them.
🎓 Module 16 : Enterprise Architecture & Governance Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This module covered the strategic, architectural, and governance aspects of Active Directory at an enterprise scale. You are now equipped to design, manage, and govern AD in complex, regulated, and large‑scale environments.
Congratulations on completing all 16 modules! You have mastered Active Directory from fundamentals to advanced enterprise architecture.
Module 17 : Advanced Troubleshooting & Performance Optimization for Active Directory
This module provides a comprehensive deep dive into troubleshooting techniques and performance optimization for Active Directory. You will learn to diagnose common error codes, resolve replication issues with Repadmin, analyze performance counters, debug slow logons and LDAP queries, capture and interpret AD network traffic with Wireshark, analyze event logs, troubleshoot SYSVOL replication (DFSR vs FRS), resolve DNS issues, tune performance for large directories, and master essential tools like LDP, ADSI Edit, and NTDSUtil. This module equips you with the skills to quickly identify and resolve even the most complex AD problems.
17.1 Common Active Directory Error Codes and Their Meanings
🔍 Introduction to AD Error Codes
Active Directory errors often manifest as cryptic hex codes or status messages in event logs, command outputs, or user-facing dialogs. Understanding these codes is the first step in troubleshooting. This section covers the most common error codes, their meanings, and typical resolutions.
Error codes are like diagnostic trouble codes in a car. They tell you where to look, but you still need to interpret them correctly to fix the problem.
📋 Common Error Codes Table
| Error Code (Hex) | Error Code (Decimal) | Symbolic Name | Description | Common Causes / Fixes |
|---|---|---|---|---|
| 0x525 | 1317 | ERROR_NO_SUCH_USER | The specified user does not exist. | Typo in username, account deleted, or replication delay. Verify account exists. |
| 0x52e | 1326 | ERROR_LOGON_FAILURE | Logon failure: unknown username or bad password. | Incorrect password, account locked, or “User must change password” flag. Check credentials and account status. |
| 0x530 | 1328 | ERROR_ACCOUNT_RESTRICTION | Account restrictions prevent this user from signing in. | Logon hours restriction, workstation restriction, or account disabled. Check account properties. |
| 0x532 | 1330 | ERROR_PASSWORD_EXPIRED | The password of this user has expired. | User must change password at next logon. Reset password or enable “Password never expires” (not recommended). |
| 0x533 | 1331 | ERROR_ACCOUNT_DISABLED | The user's account has been disabled. | Account is disabled. Enable in ADUC or PowerShell. |
| 0x534 | 1332 | ERROR_NONE_MAPPED | No mapping between account names and security IDs was done. | SID mismatch or trust issue. Check trusts and SID history. |
| 0x539 | 1337 | ERROR_ACCOUNT_LOCKED_OUT | The account is locked out. | Too many bad password attempts. Unlock account and investigate source of lockouts. |
| 0x56f | 1391 | ERROR_DS_DRA_BAD_DN | Replication failure due to bad distinguished name. | Corrupt object or lingering object. Use repadmin /removelingeringobjects. |
| 0x6fa | 1786 | ERROR_DS_DRA_INTERNAL_ERROR | Internal replication error. | Check network, permissions, or USN rollback. Event logs may provide more detail. |
| 0x200f | 8207 | ERROR_DS_DRA_REF_ALREADY_EXISTS | Replication reference already exists. | Duplicate connection object. Let KCC rebuild or manually remove. |
| 0x2016 | 8214 | ERROR_DS_DRA_MISSING_PARENT | Replication failed because object's parent is missing. | Parent object deleted. Restore from backup or authoritative restore. |
| 0x2030 | 8240 | ERROR_DS_DRA_BAD_INSTANCE_TYPE | Instance type mismatch. | Replication partner not a writeable DC. Check partner type. |
| 0x2040 | 8256 | ERROR_DS_DRA_REF_NOT_FOUND | Replication reference not found. | KCC needs to rebuild topology. Run repadmin /kcc. |
| 0x2077 | 8311 | ERROR_DS_DRA_SOURCE_DISABLED | Source DC is disabled or not responding. | Check source DC health, network connectivity. |
| 0x20c1 | 8385 | ERROR_DS_DRA_PREEMPTED | Replication was pre‑empted by higher priority request. | Normal in some cases. If persistent, check replication load. |
| 0x20d2 | 8402 | ERROR_DS_DRA_MAILBOX_INCONSISTENT | Mailbox inconsistency (usually with Exchange). | Check Exchange health and mailbox database consistency. |
| 0x20d6 | 8406 | ERROR_DS_DRA_OUT_SCHEDULE_WINDOW | Replication not attempted because outside schedule window. | Normal – wait for schedule or adjust site link schedule. |
| 0x20f1 | 8433 | ERROR_DS_DRA_SCHEMA_MISMATCH | Schema mismatch between replication partners. | Schema version differs. Ensure both DCs have same schema version. |
| 0x2138 | 8504 | ERROR_DS_DRA_CANT_FIND_SOURCE | Can't find source DC for replication. | DNS issue, SRV records missing. Check DNS and connectivity. |
| 0x216d | 8557 | ERROR_DS_DRA_RPC_CANCELLED | RPC connection cancelled. | Network timeout or firewall issue. Check RPC connectivity. |
| 0x2185 | 8581 | ERROR_DS_DRA_SOURCE_RECYCLED | Source object has been recycled (Recycle Bin). | Object was deleted and recycled. Normal; no action needed. |
| 0x218c | 8588 | ERROR_DS_DRA_REPL_SECRETS | Replication secrets (trust passwords) mismatch. | Trust relationship issue. Reset trust. |
🛠️ Using net helpmsg
For any Windows error code, you can use the command net helpmsg <code> to get a description. For example:
net helpmsg 1326 # Returns "Logon failure: unknown user name or bad password."
🔍 Where to Find Error Codes
- Event Viewer: Look in Directory Service, System, and Application logs. Error codes are often in the event details.
- Repadmin output: Replication errors show hex codes like 0x216d.
- Command-line tools: Dcdiag, nltest, etc., return error codes.
- Client-side: Logon failures may show these codes in the user interface or in logs.
17.2 Replication Troubleshooting with Repadmin
🔄 Repadmin – The Replication Administrator's Swiss Army Knife
Repadmin (Replication Administrator) is the command‑line tool for diagnosing and managing Active Directory replication. It is part of the Remote Server Administration Tools (RSAT) and is essential for any AD administrator. This section covers advanced repadmin commands and scenarios.
Repadmin is like a stethoscope for AD replication – it lets you listen to the heartbeat of replication, detect irregularities, and sometimes fix them.
📋 Essential Repadmin Commands (Refresher)
| Command | Description | Example |
|---|---|---|
repadmin /replsummary | Summarizes replication status across all DCs. | repadmin /replsummary |
repadmin /showrepl | Displays detailed replication status per DC. | repadmin /showrepl DC01 |
repadmin /syncall | Forces replication with all partners. | repadmin /syncall /e /A /P /d /q |
repadmin /queue | Shows pending replication operations. | repadmin /queue DC01 |
repadmin /failcache | Displays recent replication failures. | repadmin /failcache * |
repadmin /bridgeheads | Lists bridgehead servers per site. | repadmin /bridgeheads |
repadmin /kcc | Forces KCC to recalculate topology. | repadmin /kcc DC01 |
repadmin /removelingeringobjects | Removes lingering objects (use with caution). | repadmin /removelingeringobjects DC01 dc=contoso,dc=com /advisory_mode |
🔍 Step‑by‑Step Replication Troubleshooting
- Run
repadmin /replsummary. Look for any DCs with errors in the “Source” or “Destination” columns. Note the error count and the last success time. - For each failing DC, run
repadmin /showrepl <DC>. Examine the inbound replication connections. Look for “last attempt” and “last success” times. If “last success” is far in the past, you have a problem. - Note the error codes in
/showreploutput. For example,0x216d (RPC_CANCELLED). Use the error code table (17.1) to understand the issue. - Run
repadmin /failcache *to see a history of recent failures. This can help identify patterns. - Check replication queue with
repadmin /queue <DC>. A large queue indicates the DC is falling behind. - Test network connectivity and RPC: Use
ping,telnet <DC> 135, andrepadmin /showrepl <DC> /repstoto test connections. - Check DNS: Ensure the failing DC can resolve the names of its replication partners. Use
nslookupordcdiag /test:dns. - Force KCC recalculation: If topology seems wrong, run
repadmin /kcc <DC>on each DC. - Force replication: If you've fixed the underlying issue, run
repadmin /syncall /e /A /P /d /qto attempt a full sync.
🔄 Dealing with Lingering Objects
Lingering objects are objects that have been deleted on some DCs but not on others. They can cause replication errors (0x56f, 0x2016). To identify and remove them:
- Use
repadmin /removelingeringobjects <DC> <partitionDN> /advisory_modeto see what would be removed. - If safe, run without
/advisory_modeto actually remove. - Note: This is a last resort. It's better to bring all DCs within the tombstone lifetime.
📊 Example: Diagnosing a Failed Replication
C:\> repadmin /replsummary
Replication Summary Start Time: 2023-10-26 10:00:00
Beginning data collection for replication summary, this may take a while:
....
Source DC Largest Delta Fails
DC01.contoso.com 15m:22s 0
DC02.contoso.com 05m:10s 2
DC03.contoso.com 01d:04h:15m 5 <-- Problem!
Destination DC Largest Delta Fails
DC03.contoso.com 01d:04h:15m 3 <-- Failing as source and destination
C:\> repadmin /showrepl DC03.contoso.com
...
DC=contoso,CN=Configuration,DC=contoso,DC=com
Default-First-Site-Name\DC02 via RPC
DC object GUID:
Last attempt @ 2023-10-26 09:45:23 failed with 0x216d (RPC_CANCELLED)
Last success @ 2023-10-25 07:30:10
...
This indicates DC03 has not replicated in over a day, with RPC errors. Troubleshoot network connectivity and RPC ports between DC03 and DC02.
17.3 Analyzing Active Directory Performance Counters
📈 Why Performance Counters Matter
Windows Performance Monitor (PerfMon) provides a wealth of counters specific to Active Directory. Monitoring these counters helps you identify bottlenecks, capacity issues, and abnormal behaviour before they affect users.
Performance counters are like the gauges on your car's dashboard. They tell you how hard the engine is working, how much fuel is left, and if anything is overheating.
📋 Key AD Performance Counters
| Counter Object | Counter Name | What It Measures | Threshold / Notes |
|---|---|---|---|
| NTDS | DRA Inbound Bytes Total/sec | Replication traffic inbound. | Spikes indicate replication activity. Baseline then monitor for anomalies. |
| NTDS | DRA Outbound Bytes Total/sec | Replication traffic outbound. | Same as above. |
| NTDS | DRA Pending Replication Synchronizations | Number of pending replication operations. | Should be low (0-1). High indicates backlog. |
| NTDS | LDAP Client Sessions | Number of connected LDAP clients. | Track for capacity planning. |
| NTDS | LDAP Searches/sec | Rate of LDAP search operations. | High sustained rates may indicate inefficient queries or application issues. |
| NTDS | Kerberos Authentications/sec | Rate of Kerberos ticket requests. | Spikes correlate with logon bursts. |
| NTDS | NTLM Authentications/sec | Rate of NTLM authentications. | High NTLM may indicate Kerberos failures or legacy apps. |
| Processor | % Processor Time (_Total) | Overall CPU usage. | Sustained >80% may indicate need for more CPU. |
| Memory | Available MBytes | Available physical memory. | Should be >200 MB at least. Low memory causes paging. |
| Memory | Pages/sec | Rate of hard page faults. | High (>100) indicates memory pressure. |
| LogicalDisk | Avg. Disk sec/Read (NTDS drive) | Average read latency for AD database disk. | Should be <20 ms. >50 ms indicates disk bottleneck. |
| LogicalDisk | Avg. Disk sec/Write (Log drive) | Average write latency for transaction logs. | Should be <10 ms. Log writes are sequential; high latency slows transactions. |
| Network Interface | Bytes Total/sec | Network throughput. | Compare to interface capacity. Sustained near 100% indicates need for faster NIC. |
⚙️ Using Performance Monitor
- Open Performance Monitor (perfmon.msc).
- Add counters (Ctrl+N) and select the NTDS object and the counters of interest.
- For historical analysis, use Data Collector Sets to log counters over time.
- For real‑time monitoring, set alerts in PerfMon or integrate with a monitoring tool like SCOM, PRTG, or Zabbix.
🔍 What to Look For
- LDAP Searches/sec: A sudden spike may indicate an application performing inefficient queries or a denial‑of‑service attack. Investigate source IP.
- DRA Pending Replications: If this stays above 0 for extended periods, replication is falling behind. Check network or source DC performance.
- Disk latency: High latency on the NTDS drive suggests need for faster storage (e.g., SSD). High latency on logs may indicate the drive is too slow or the log is on the same drive as the database.
- CPU: Sustained high CPU may be due to many authentication requests, inefficient LDAP queries, or simply underpowered hardware.
📊 Example: Baseline and Alerting
Establish a baseline during normal operation. For example, note the typical LDAP Searches/sec during business hours. Set alerts for values exceeding 2‑3 times the baseline.
17.4 Debugging LDAP Queries & Slow Logons
🐢 The Problem of Slow Logons
Slow logons are one of the most common user complaints. They can be caused by many factors: network latency, overloaded DCs, inefficient LDAP queries, Group Policy processing, or profile loading. This section focuses on debugging LDAP queries and other AD‑related causes.
Slow logons are like a slow checkout line. You need to figure out if the cashier is slow (DC), the scanner is broken (LDAP), or the customer has too many coupons (Group Policy).
🔍 Enabling LDAP Logging
Windows can log LDAP operations to the event log for debugging. To enable:
- Open Registry Editor on the DC.
- Navigate to
HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Diagnostics. - Set the value “15 Field Engineering” to a number (e.g., 1 or 2). 1 logs errors, 2 logs more detail, 5 logs everything.
- Restart the NTDS service or reboot.
- Look for events in the Directory Service log (Event ID 1644, 1645, etc.).
Note: This generates many events. Turn it off after debugging.
📋 Event ID 1644 – Expensive LDAP Queries
Event ID 1644 logs LDAP queries that took a long time to complete or returned many results. It includes the client IP, the query string, the search base, and the time taken. This is invaluable for identifying inefficient queries.
Example: A query for (objectCategory=person) without an index can cause a full scan of the directory.
🛠️ Tools for LDAP Analysis
- LDP.exe: Can run LDAP queries and show response times.
- ADInsight (Sysinternals): Monitors LDAP traffic between applications and DCs. Useful for seeing which application is making which queries.
- Wireshark: Capture LDAP traffic and analyze query patterns.
📊 Step‑by‑Step: Debugging Slow Logons
- Identify scope: Is the problem isolated to one user, one computer, one site, or all users?
- Check baseline: Compare logon times with a known good client.
- Use Group Policy Modeling/Results: In GPMC, run a modeling wizard to see which GPOs apply and how many.
- Enable verbose logon messages: Configure GPO to display verbose status messages during logon. This shows which phase is slow (Group Policy, profile load, etc.).
- Check network latency: Use
pingandpathpingto measure latency to the authenticating DC. - Check DC load: Use Performance Monitor (17.3) to see if the DC is overloaded.
- Enable LDAP logging: Look for expensive queries (Event ID 1644). Common culprits:
- Queries with
(objectClass=*)(scan all objects). - Queries without indexed attributes.
- Queries returning many objects (e.g., “all users”).
- Queries with
- Check Group Policy processing: Enable Group Policy operational logging (Event Viewer → Applications and Services Logs → Microsoft → Windows → GroupPolicy). Look for slow processing.
- Check profile loading: If using roaming profiles, check network share latency and profile size.
🔁 Optimizing LDAP Queries
- Ensure applications use indexed attributes for filtering (e.g.,
sAMAccountName,userPrincipalName,objectSID). - Avoid queries with
(objectClass=*)or(objectCategory=*). - Limit the search base to a specific OU, not the entire domain.
- Use Global Catalog (port 3268) for forest‑wide searches.
17.5 Using Wireshark for Active Directory Traffic Analysis
📡 Why Capture Network Traffic?
Sometimes, the problem lies in the network. Wireshark (or Microsoft Message Analyzer) can capture and decode AD traffic, revealing issues like packet loss, retransmissions, malformed packets, or authentication protocol details that event logs miss.
Wireshark lets you see the raw conversation between a client and a DC. It's like listening to the actual phone call instead of just reading the call summary.
🔍 Key AD Protocols to Capture
- Kerberos (TCP/UDP 88): Authentication traffic. Can reveal ticket errors, encryption types, and pre‑authentication issues.
- LDAP (TCP 389, 636): Directory queries. See actual queries and responses.
- LDAP over SSL (TCP 636): Encrypted traffic – you'll need the server's private key to decrypt.
- Global Catalog (TCP 3268, 3269): Forest‑wide searches.
- DNS (UDP/TCP 53): SRV record lookups.
- SMB (TCP 445): SYSVOL access, Group Policy.
- RPC (dynamic ports): Replication and other RPC‑based services.
⚙️ Capturing Traffic with Wireshark
- Install Wireshark on the client or DC (or use a network tap).
- Apply a capture filter to reduce noise. For example:
host 192.168.1.10 or port 88 or port 389. - Start capture, reproduce the issue, then stop.
- Use display filters to focus on relevant traffic. Common display filters:
kerberos– Show only Kerberos traffic.ldap– Show LDAP traffic.dns.qry.name contains "_ldap"– Show DNS SRV queries.tcp.analysis.flags– Show TCP retransmissions or other errors.
🔍 What to Look For
- TCP retransmissions: Indicate packet loss or network congestion. Look for
tcp.analysis.retransmission. - Kerberos errors: Look for Kerberos error packets (e.g., KRB_ERROR). Decode them to see the error code.
- Slow LDAP responses: Time between LDAP request and response. If consistently high, DC may be overloaded.
- DNS failures: Look for DNS queries that fail or return incorrect SRV records.
- Authentication protocol: See if client is using Kerberos or falling back to NTLM. NTLM traffic appears as MSRPC.
📊 Example: Diagnosing Kerberos Failure
A user reports authentication failure. Wireshark capture shows:
- Client sends AS‑REQ (Kerberos ticket request).
- DC responds with KRB_ERROR, error code: KDC_ERR_PREAUTH_FAILED.
- This indicates the user's pre‑authentication timestamp was incorrect – likely a time skew issue. Check client time sync.
🔐 Decrypting LDAPS Traffic
If you need to inspect encrypted LDAPS (port 636), you can:
- Configure the DC to export its private key (not recommended for production).
- Use a network tap that performs SSL interception.
- Focus on the unencrypted Kerberos and DNS portions, which often provide enough clues.
17.6 Event Log Analysis for Active Directory
📋 The Event Log Goldmine
Active Directory logs a vast amount of information in the Windows Event Logs. Knowing where to look and what to look for is essential for troubleshooting and security monitoring.
🔍 Key Event Logs for AD
- Directory Service Log: Located in Event Viewer under “Windows Logs”. Contains AD‑related events: replication, service start/stop, database errors.
- DNS Server Log: If the DC runs DNS, check for DNS errors.
- Security Log: Contains authentication events (4624, 4625, 4768, 4769), account management (4720‑4728), and directory service access (4662).
- System Log: Service start/stop, network issues, hardware errors.
- Application Log: Errors from applications that use AD (e.g., Exchange).
- DFS Replication Log: If using DFSR for SYSVOL, this log contains SYSVOL replication events.
- Group Policy Operational Log: Under Applications and Services Logs → Microsoft → Windows → GroupPolicy. Detailed GPO processing logs.
📋 Critical Event IDs to Monitor
This table expands on the one in 12.9, adding troubleshooting‑focused events.
| Event ID | Log | Description | Troubleshooting Use |
|---|---|---|---|
| 103, 105 | Directory Service | NTDS service start/stop. | Check if AD DS started correctly. |
| 1126 | Directory Service | NTDS database integrity check. | Indicates database check; errors may indicate corruption. |
| 1168 | Directory Service | NTDS database error. | Corruption or disk issues. |
| 1311 | Directory Service | KCC unable to build topology. | Site link misconfiguration. |
| 1864 | Directory Service | Replication failure due to many errors. | Severe replication problem. |
| 1925 | Directory Service | Failed to establish replication link. | Network or DNS issue. |
| 1988 | Directory Service | Lingering object detected. | Run repadmin /removelingeringobjects. |
| 2042 | Directory Service | Too long since replication (tombstone lifetime exceeded). | DC must be demoted. |
| 2886 | Directory Service | Kerberos error. | Check time sync, SPNs. |
| 1644 | Directory Service | Expensive LDAP query. | Optimize query or application. |
| 4624 | Security | Successful logon. | Track user activity. |
| 4625 | Security | Failed logon. | Brute‑force detection, password issues. |
| 4648 | Security | Logon with explicit credentials. | Detect runas usage, lateral movement. |
| 4672 | Security | Special privileges assigned. | Admin logon detection. |
| 4720 | Security | User created. | Audit account creation. |
| 4728/4732/4756 | Security | Group member added. | Audit group changes. |
| 4768 | Security | Kerberos TGT requested. | Monitor for unusual requests. |
| 4769 | Security | Kerberos service ticket requested. | Kerberoasting detection. |
| 4776 | Security | NTLM authentication. | Monitor NTLM usage. |
| 5136 | Security | Directory service object modified. | Track changes to AD objects. |
| 5137 | Security | Directory service object created. | Track new objects. |
| 5141 | Security | Directory service object deleted. | Track deletions. |
🛠️ Analyzing Events with PowerShell
# Find all replication errors in the last 24 hours
$cutoff = (Get-Date).AddHours(-24)
Get-WinEvent -LogName "Directory Service" -MaxEvents 100 | Where-Object { $_.TimeCreated -ge $cutoff -and $_.Id -in (1925,1988,2042,1864) } | Format-Table TimeCreated, Id, Message -AutoSize
# Find failed logons for a specific user
Get-WinEvent -LogName Security -FilterXPath "*[System[EventID=4625]]" -MaxEvents 100 | Where-Object { $_.Properties[5].Value -eq "jsmith" } | Format-Table TimeCreated, Message
📊 Forwarding Events to a SIEM
For proactive monitoring, forward critical AD events to a SIEM (e.g., Azure Sentinel, Splunk). This enables correlation and alerting.
17.7 SYSVOL Replication: DFSR vs FRS
📁 What is SYSVOL?
SYSVOL is a shared folder on domain controllers that stores Group Policy templates and logon scripts. It must be replicated between all DCs in a domain. Historically, SYSVOL replication was handled by the File Replication Service (FRS). Starting with Windows Server 2008, the recommended replication engine is the Distributed File System Replication (DFSR). Windows Server 2008 R2 and later require DFSR for new domains, but older domains may still use FRS.
🔄 FRS vs DFSR – Key Differences
| Feature | FRS (File Replication Service) | DFSR (Distributed File System Replication) |
|---|---|---|
| Replication algorithm | File‑based, uses NTFRS API | Remote Differential Compression (RDC) – replicates only changes |
| Bandwidth efficiency | Low – replicates entire files | High – replicates only changed blocks |
| Scalability | Poor for large files/number of files | Good, even with many files |
| Staging folder | Required, can fill up | More efficient, less prone to filling |
| Conflict resolution | Last writer wins | More sophisticated, with conflict files |
| Supported on | Windows 2000, 2003, 2008 (deprecated) | Windows Server 2008 and later |
⚠️ FRS Deprecation
Microsoft deprecated FRS in Windows Server 2008 R2. Domains created on Windows Server 2008 or later use DFSR by default. If you have an older domain still using FRS, you should migrate to DFSR as soon as possible. FRS is unsupported on newer Windows Server versions.
🛠️ Troubleshooting SYSVOL Replication
Common SYSVOL issues:
- GPOs not appearing on all DCs.
- Event IDs 13508 (DFSR) or 13565 (DFSR) indicating replication failures.
- Event IDs 13553, 13554 (FRS) indicating FRS errors.
DFSR troubleshooting tools:
dfsrdiag– Command‑line tool for DFSR diagnostics. Common commands:dfsrdiag ReplicationState /member:DC01– Show replication state.dfsrdiag Backlog /member:DC01 /rgname:"Domain System Volume"– Show pending files.
- DFS Management Console: View replication groups and backlog.
- Event Viewer: Look in “Applications and Services Logs → DFS Replication”.
FRS troubleshooting tools:
nltest /dsgetsite– Verify site membership.net share– Ensure SYSVOL is shared.frsdiag– FRS diagnostic tool (older).
🔄 Migrating from FRS to DFSR
Microsoft provides a step‑by‑step migration guide. The process involves:
- Prepare the domain (ensure all DCs are running at least Windows Server 2008).
- Raise the domain functional level to Windows Server 2008 or higher.
- Use the DFSRMIG tool (
dfsrmig.exe) to migrate.- State 0: FRS.
- State 1: Prepared (both FRS and DFSR run).
- State 2: Redirected (clients use DFSR).
- State 3: Eliminated (FRS disabled).
- Monitor with
dfsrmig /getglobalstate.
Note: Once you move to State 3, you cannot revert to FRS.
17.8 DNS Troubleshooting for Active Directory
🌐 DNS – The Achilles' Heel of AD
As covered in Module 5, AD is completely dependent on DNS. Most AD issues can be traced back to DNS misconfigurations. This section provides advanced DNS troubleshooting techniques.
If AD is a house, DNS is the address system. If the address system is broken, no one can find the house.
🔍 Common DNS Symptoms
- Clients cannot find a domain controller (logon delays, “No domain controller found”).
- Replication failures (DNS errors).
- GPOs not applying.
- Group Policy errors: “The system cannot find the file specified”.
🛠️ DNS Troubleshooting Steps
- Verify client DNS settings: Client must point to internal DNS servers that can resolve the domain. Use
ipconfig /all. - Check SRV records: Use
nslookup -type=SRV _ldap._tcp.dc._msdcs.contoso.com. Should return list of DCs. If not, troubleshoot DC registration. - Check zone replication: If using AD‑integrated zones, ensure zones are replicating. Use
repadmin /showreplto check replication of the domain DNS partitions. - Test dynamic updates: Ensure DCs can update their own records. Check Event ID 5774 (DNS registration success/failure).
- Run
dcdiag /test:dns: Comprehensive DNS test on DCs. Look for failures. - Check for stale records: Use DNS scavenging to remove old records. Configure scavenging on zones.
- Verify reverse lookup zones: Not critical for AD, but useful for some applications.
📋 Advanced DNS Checks
- Check for duplicate SRV records: Multiple identical records can cause load‑balancing issues but are not fatal.
- Verify the
_msdcszone delegation: For child domains, ensure delegation records are correct. - Use
dnscmdto examine zone details:dnscmd /enumrecords contoso.com _msdcs.
🔄 Fixing Missing SRV Records
If SRV records are missing, force the DC to re‑register them:
# Restart Netlogon service on the DC (reregisters SRV records)
net stop netlogon && net start netlogon
# Alternatively, force registration with nltest
nltest /dsregdns
🔁 DNS and Site Awareness
Clients use SRV records for site awareness. They query _ldap._tcp.<site>._sites.dc._msdcs.domain. If subnets are not defined or site‑specific SRV records are missing, clients may use DCs from other sites. Ensure subnets are correctly assigned.
17.9 Performance Tuning for Large Directories
📈 Optimizing AD for Scale
As your directory grows (hundreds of thousands or millions of objects), performance tuning becomes critical. This section covers techniques to maintain responsiveness.
📊 Indexing Attributes
Queries that filter on unindexed attributes cause full scans of the database, which is slow in large directories. Index frequently queried attributes.
How to index an attribute:
- Open ADSI Edit, connect to the Schema partition.
- Find the attribute (e.g.,
department). - Right‑click → Properties, and set the
searchFlagsattribute to:1– Indexed.7– Indexed and also for tuple (for substring searches).
- After indexing, the change replicates. It may take time for the index to build.
Commonly indexed attributes: sAMAccountName, userPrincipalName, displayName, department, title.
💾 Database and Log Placement
- Place the NTDS.DIT database and logs on separate physical disks (or at least separate virtual disks).
- Use fast, low‑latency storage (SSD) for both. Logs benefit from low write latency; database benefits from low read/write latency.
- Monitor disk performance (see 17.3).
🔄 Replication Tuning
- Adjust site link schedules and intervals to balance latency and bandwidth.
- Consider using multiple bridgehead servers in large sites to load‑balance replication.
- Monitor replication backlog and adjust as needed.
⚙️ GC Placement
In very large forests, having every DC as a GC may cause excessive replication. Strategically place GCs in major sites and use universal group caching in smaller sites.
📦 Global Catalog and Universal Group Caching
As covered in 11.9, universal group caching reduces the need for GCs in branch sites. Enable it in site properties.
🔍 Monitoring and Baselines
Establish performance baselines during normal operation. Monitor for deviations. Use Performance Monitor to track:
- LDAP Searches/sec – a sharp increase may indicate a new application or inefficient query.
- Average LDAP search time – should be consistent.
- Processor and memory usage.
📋 Recommendations for Very Large Directories (>1 million objects)
- Use 64‑bit hardware with ample RAM (32 GB+).
- Ensure all DCs are 64‑bit.
- Consider using multiple domains to partition the directory (though this adds complexity).
- Use read‑only domain controllers in branch offices to reduce write load.
- Implement a robust change management process to avoid frequent large‑scale changes.
17.10 Essential Tools: LDP, ADSI Edit, and NTDSUtil
🛠️ The Power Trio
Beyond the standard GUI tools, three utilities are indispensable for advanced troubleshooting and management: LDP, ADSI Edit, and NTDSUtil. Each serves a distinct purpose.
🔍 LDP (LDAP Browser/Editor)
LDP is a graphical tool that allows you to perform LDAP operations (bind, search, add, modify, delete) against any LDAP directory, including AD. It's invaluable for testing LDAP queries, viewing raw attributes, and troubleshooting authentication.
Common uses:
- Test LDAP connectivity: Connect to a DC on port 389 (LDAP) or 636 (LDAPS).
- View raw object attributes: See all attributes of an object, including constructed ones.
- Run custom LDAP queries: Test complex filters before using them in applications.
- Modify attributes directly: When ADUC doesn't expose a particular attribute.
How to use:
- Run
ldp.exefrom the Run dialog (it's part of RSAT). - From the menu, Connection → Connect. Enter a DC name and port.
- Connection → Bind. Choose credentials.
- View → Tree. Enter a base DN to browse.
- Browse → Search to run custom queries.
✏️ ADSI Edit (Active Directory Services Interfaces Editor)
ADSI Edit is a low‑level editor for Active Directory. It allows you to view, modify, create, and delete objects in any AD partition (domain, configuration, schema). It's more powerful than ADUC and should be used with extreme caution.
Common uses:
- Modify the schema: Add or modify attributes (requires Schema Admin).
- Clean up metadata: Remove orphaned objects after a failed DC demotion.
- View configuration partition: Explore sites, services, and other forest‑wide settings.
- Change attributes not exposed in ADUC: e.g., modify the
adminCountattribute.
How to use:
- Run
adsiedit.mscfrom the Run dialog (part of RSAT). - Right‑click ADSI Edit → Connect to. Choose a well‑known naming context (Domain, Configuration, Schema) or enter a DN.
- Browse the tree and right‑click objects to modify.
⚠️ Caution: ADSI Edit bypasses all validation and can break your directory if misused. Always have a current backup before making changes.
⚙️ NTDSUtil (Active Directory Database Utility)
NTDSUtil is the command‑line tool for managing the AD database. It's used for offline maintenance, authoritative restores, metadata cleanup, and more. We've covered it in Module 9.
Common uses:
- Offline defragmentation (compact):
ntdsutil → files → compact to C:\temp. - Authoritative restore:
ntdsutil → authoritative restore → restore subtree "OU=Sales,DC=contoso,DC=com". - Metadata cleanup: Remove a failed DC from AD.
- Reset Directory Services Restore Mode (DSRM) password:
ntdsutil → set dsrm password. - Database integrity check:
ntdsutil → semantic database analysis → go.
How to use:
ntdsutil
? # for help
quit # to exit
📊 When to Use Each Tool
| Task | Tool |
|---|---|
| Test LDAP query | LDP |
| View all attributes of an object | LDP or ADSI Edit |
| Modify an attribute not in ADUC | ADSI Edit |
| Clean up metadata after failed DC | NTDSUtil |
| Perform authoritative restore | NTDSUtil |
| Compact the database | NTDSUtil |
| Modify the schema | ADSI Edit (or schema snap‑in) |
| Reset DSRM password | NTDSUtil |
🎓 Module 17 : Advanced Troubleshooting & Performance Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This module covered the most advanced troubleshooting techniques, performance tuning, and essential tools for Active Directory. You are now equipped to diagnose and resolve complex issues, optimize performance, and maintain a healthy AD environment.
Congratulations on completing all 17 modules! You have mastered Active Directory from fundamentals to advanced troubleshooting and enterprise architecture.
Module 18 : Hands-On Labs & Real-World Scenarios
This module provides practical, hands-on lab exercises that simulate real‑world Active Directory scenarios. You will build a multi‑site lab environment, simulate domain controller failures and recoveries, deploy Read‑Only Domain Controllers (RODC), configure Fine‑Grained Password Policies (FGPP), perform a Kerberoasting attack and analyze it with BloodHound, deploy Microsoft Defender for Identity, migrate AD to Azure using Azure Migrate, create custom PowerShell reports, and participate in an incident response simulation. Each lab includes detailed step‑by‑step instructions, explanations, and best practices to reinforce your learning.
18.1 Building a Multi-Site Active Directory Lab
🎯 Lab Objective
In this lab, you will build a multi‑site Active Directory environment using virtual machines (Hyper‑V, VMware, or Azure). This lab will simulate two physical sites (e.g., New York and London) with domain controllers in each site, site links, and subnets. You will configure replication and verify site awareness.
Multi‑site AD is common in enterprises. Understanding site topology, replication, and client affinity is essential for designing and troubleshooting distributed environments.
📋 Prerequisites
- Virtualization platform (Hyper‑V, VMware Workstation, or VirtualBox) with at least 3 VMs:
- DC1 (New York): Windows Server 2022 (or 2019)
- DC2 (London): Windows Server 2022 (or 2019)
- Client (Workstation): Windows 10/11
- Sufficient RAM (at least 8‑12 GB for all VMs).
- Basic knowledge of AD installation.
🛠️ Step 1: Deploy the First Domain Controller (New York)
- Install Windows Server on VM DC1.
- Set a static IP address (e.g., 192.168.1.10/24) and DNS to itself (127.0.0.1).
- Rename the computer to
DC1-NYand reboot. - Install Active Directory Domain Services role:
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
- Promote to a domain controller in a new forest:
Install-ADDSForest -DomainName "lab.contoso.com" -SafeModeAdministratorPassword (ConvertTo-SecureString "P@ssw0rd123" -AsPlainText -Force)
- After reboot, verify the installation with
Get-ADDomain.
🛠️ Step 2: Deploy the Second Domain Controller (London)
- Install Windows Server on VM DC2.
- Set a static IP on a different subnet to simulate WAN (e.g., 192.168.2.10/24). Configure DNS to point to DC1 (192.168.1.10). Ensure routing between subnets (e.g., add a route or use a virtual router).
- Rename computer to
DC2-LONand reboot. - Join the domain:
Add-Computer -DomainName "lab.contoso.com" -Credential lab\Administrator -Restart. - Install AD DS role and promote as an additional DC:
Install-ADDSDomainController -DomainName "lab.contoso.com" -SafeModeAdministratorPassword (ConvertTo-SecureString "P@ssw0rd123" -AsPlainText -Force)
🛠️ Step 3: Create Sites and Subnets
- Open Active Directory Sites and Services on any DC.
- Rename
Default-First-Site-Nameto NewYork. - Create a new site named London. Add it to the
DEFAULTIPSITELINK. - Create subnets:
- Right‑click Subnets → New Subnet:
192.168.1.0/24→ select site NewYork. - New Subnet:
192.168.2.0/24→ select site London.
- Right‑click Subnets → New Subnet:
- Move the DC computer objects to the correct sites:
- Expand NewYork → Servers → DC1-NY should already be there.
- Expand London → right‑click Servers → New → Server → name DC2-LON.
- In the London site, you will see DC2-LON. (You may need to drag it or create it correctly).
🛠️ Step 4: Configure Site Link
- In Sites and Services, expand Inter‑Site Transports → IP.
- Right‑click DEFAULTIPSITELINK → Properties.
- Set a cost (e.g., 100) and replication interval (e.g., 15 minutes for lab).
- Add both sites to the link if not already there.
🛠️ Step 5: Verify Replication and Site Awareness
- On DC1, run
repadmin /replsummaryto verify replication with DC2. - On the Windows 10 client, join the domain and ensure it gets an IP in the New York subnet (192.168.1.x).
- On the client, run
nltest /dsgetdc:lab.contoso.com. It should return DC1 (local site). - Change the client’s IP to the London subnet (192.168.2.x) and run
nltest /dsgetdcagain – it should return DC2.
18.2 Simulating a Domain Controller Failure & Recovery
🎯 Lab Objective
In this lab, you will simulate a domain controller failure and practice recovery procedures, including non‑authoritative restore and metadata cleanup. This is a critical skill for real‑world disaster recovery.
📋 Prerequisites
- Multi‑site lab from Lab 18.1 (with at least two DCs).
- Backup of DC1 (system state) using Windows Server Backup.
🛠️ Step 1: Take a System State Backup of DC1
- On DC1, install Windows Server Backup (if not installed):
Install-WindowsFeature -Name Windows-Server-Backup. - Open Windows Server Backup, right‑click → Backup Once (or schedule).
- Select “Different options” → “Custom” → “Add items” → check “System state”.
- Choose a backup destination (local volume or network share). For lab, use a local drive (e.g., D:).
- Complete the backup. Note the location.
🛠️ Step 2: Simulate DC Failure
- On DC1, stop the Active Directory Domain Services service:
net stop ntds. - Alternatively, you can simulate a hard failure by shutting down the VM or disconnecting its network.
- On DC2, verify that DC1 is not replicating:
repadmin /replsummaryshould show DC1 as failing.
🛠️ Step 3: Recover DC1 via Non‑Authoritative Restore
- Boot DC1 into Directory Services Restore Mode (DSRM):
- Restart the VM, press F8 during boot, select “Directory Services Restore Mode”.
- Log in with the DSRM password (set during promotion).
- Open an elevated command prompt.
- Run
wbadmin get versionsto find the backup version. - Restore system state:
wbadmin start systemstaterecovery -version:MM/DD/YYYY-HH:MM -backupTarget:d: - When prompted, confirm restore. Wait for completion.
- After restore, exit DSRM and reboot normally.
🛠️ Step 4: Verify Recovery and Replication
- After reboot, check that AD DS starts. Run
dcdiag /test:replications. - On DC2, run
repadmin /replsummary. DC1 should now be replicating successfully.
🛠️ Step 5: Metadata Cleanup (If DC is Permanently Lost)
If you cannot recover DC1 (e.g., hardware failure), you must perform metadata cleanup to remove its references from AD.
- On a working DC (DC2), open ntdsutil.
- Type:
metadata cleanup connections connect to server DC2.lab.contoso.com quit select operation target list domains select domain 0 list sites select site 0 list servers in site select server
quit remove selected server quit quit - Verify in Sites and Services that the DC1 object is gone.
18.3 Implementing a Read‑Only Domain Controller (RODC)
🎯 Lab Objective
Deploy a Read‑Only Domain Controller (RODC) in a branch office site. Configure password replication policy and test authentication.
📋 Prerequisites
- Multi‑site lab from Lab 18.1.
- A new VM for RODC (Windows Server) with static IP in a new subnet (e.g., 192.168.3.10/24).
- Create a new site “Branch” and subnet 192.168.3.0/24 in Sites and Services.
🛠️ Step 1: Prepare the Domain for RODC
- Ensure the domain functional level is at least Windows Server 2003 (it is).
- Optionally, pre‑stage the RODC computer account (recommended):
Add-ADDSReadOnlyDomainControllerAccount -DomainControllerAccountName "RODC-BR" -SiteName "Branch" -DelegatedAdministratorAccountName "CONTOSO\BranchAdmin"
🛠️ Step 2: Deploy RODC
- On the new VM, set IP to 192.168.3.10, DNS to a writable DC (e.g., 192.168.1.10). Join the domain:
Add-Computer -DomainName "lab.contoso.com" -Credential lab\Administrator -Restart. - After reboot, log in as domain admin.
- Install AD DS role and promote as RODC:
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools Install-ADDSDomainController -ReadOnlyReplica -DomainName "lab.contoso.com" -SiteName "Branch" -AllowPasswordReplicationAccountName @("CONTOSO\AllowedUsers", "CONTOSO\AllowedComputers") -Credential (Get-Credential) - During promotion, you will set the DSRM password.
🛠️ Step 3: Configure Password Replication Policy
- On the RODC or any DC, open ADAC (Active Directory Administrative Center).
- Navigate to the RODC object.
- In the right pane, click Password Replication Policy.
- Add users/groups that are allowed to cache passwords (e.g., branch users).
- By default, privileged accounts (Domain Admins, etc.) are denied.
PowerShell equivalent:
Add-ADDomainControllerPasswordReplicationPolicy -Identity "RODC-BR" -AllowedList "CONTOSO\BranchUsers"
🛠️ Step 4: Test RODC Functionality
- Create a test user in the domain that is allowed to cache passwords.
- On a client in the branch subnet, attempt to log on with that user. The first logon will require contacting a writable DC (if password not cached).
- After successful first logon, the password is cached on the RODC (if allowed). Disconnect the branch from the writable DC (simulate WAN outage) and log on again – it should succeed using the cached credential.
18.4 Configuring Fine-Grained Password Policies (FGPP)
🎯 Lab Objective
Implement Fine‑Grained Password Policies (FGPP) using Password Settings Objects (PSOs) to apply different password policies to different groups of users.
📋 Prerequisites
- A functional AD domain (lab.contoso.com) with at least one DC.
- Two global security groups:
AdminsandStandardUsers.
🛠️ Step 1: Create PSOs using ADAC
- Open Active Directory Administrative Center (ADAC).
- Navigate to the domain → System → Password Settings Container.
- In the right pane, click New → Password Settings.
- Create a PSO for administrators:
- Name: AdminsPSO
- Precedence: 10 (lower number = higher priority)
- Minimum password length: 16
- Password must meet complexity requirements: True
- Store password using reversible encryption: False
- Account lockout threshold: 3
- Account lockout duration: 00:30:00
- Reset account lockout counter after: 00:30:00
- Applies to: Add the
Adminsgroup.
- Create a second PSO for standard users:
- Name: StandardPSO
- Precedence: 20
- Minimum password length: 8
- Complexity: True
- Lockout threshold: 5
- Applies to: Add the
StandardUsersgroup.
🛠️ Step 2: Create PSOs using PowerShell
# Create AdminsPSO
New-ADFineGrainedPasswordPolicy -Name "AdminsPSO" -Precedence 10 -MinPasswordLength 16 -ComplexityEnabled $true -LockoutThreshold 3 -LockoutDuration "00:30:00" -LockoutObservationWindow "00:30:00"
# Apply to group
Add-ADFineGrainedPasswordPolicySubject -Identity "AdminsPSO" -Subjects "Admins"
# Create StandardPSO
New-ADFineGrainedPasswordPolicy -Name "StandardPSO" -Precedence 20 -MinPasswordLength 8 -ComplexityEnabled $true -LockoutThreshold 5 -LockoutDuration "00:30:00" -LockoutObservationWindow "00:30:00"
Add-ADFineGrainedPasswordPolicySubject -Identity "StandardPSO" -Subjects "StandardUsers"
🛠️ Step 3: Verify PSO Application
- Create a user in the
Adminsgroup. Check the resultant PSO:Get-ADUserResultantPasswordPolicy -Identity adminuser
Should return AdminsPSO. - Create a user in the
StandardUsersgroup and verify StandardPSO. - Test password changes – the policy should enforce the respective rules.
18.5 Kerberoasting Attack Lab (Defensive Perspective)
🎯 Lab Objective
In this lab, you will simulate a Kerberoasting attack from an attacker's perspective and then implement defensive measures to detect and prevent it. This is a critical exercise for understanding the attack and how to protect against it.
📋 Prerequisites
- A domain with at least one service account (user with SPN). Create a test service account:
svc_testwith a weak password (e.g.,Password123!). Set an SPN:setspn -A HTTP/test.lab.contoso.com svc_test. - A domain‑joined Windows client with Rubeus (or you can use PowerShell).
🛠️ Step 1: Perform Kerberoasting (Attacker View)
- On the client, as a low‑privileged domain user, run Rubeus:
Rubeus.exe kerberoast /outfile:hashes.txt
This requests service tickets for all accounts with SPNs and extracts the encrypted portion. - If you don't have Rubeus, you can use native PowerShell (less efficient):
Add-Type -AssemblyName System.IdentityModel $spns = Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName foreach ($spn in $spns) { $ticket = [System.IdentityModel.Tokens.KerberosRequestorSecurityToken]::new($spn.ServicePrincipalName) # Extract ticket data (simplified – actual cracking requires more work) } - Use a tool like Hashcat to crack the extracted hash:
hashcat -m 13100 hashes.txt wordlist.txt
With a weak password, it should crack quickly.
🛠️ Step 2: Detection (Defender View)
- On a domain controller, enable advanced auditing for Kerberos service ticket requests (Event ID 4769).
- After running the attack, check the Security log for Event ID 4769. Look for:
- Service Name:
HTTP/test.lab.contoso.com - Account Name: the low‑privileged user
- Ticket Encryption Type:
0x17(RC4) – this indicates a weak encryption type often targeted by attackers.
- Service Name:
- You can create a PowerShell script to detect multiple 4769 events from the same user for different SPNs.
🛠️ Step 3: Mitigation
- Strong service account passwords: Change the service account password to a random 20+ character password. Use a password manager or gMSA.
- Use gMSAs: If possible, convert the service account to a Group Managed Service Account (gMSA). This eliminates the need for a human‑managed password.
- Disable RC4 encryption: In Group Policy, set
Network security: Configure encryption types allowed for Kerberosto only allow AES. This forces tickets to use AES, making cracking harder.
🛠️ Step 4: Re‑test After Mitigation
- After implementing mitigations, run Rubeus again. It may still request tickets, but the hash will be AES‑encrypted, which is much harder to crack.
- Check Event ID 4769 again – if RC4 is disabled, you should see only AES ticket requests (encryption type 0x12).
18.6 BloodHound Attack Path Analysis
🎯 Lab Objective
Use BloodHound to map attack paths in your AD environment, identify misconfigurations, and learn how attackers escalate privileges. Then, remediate the findings.
📋 Prerequisites
- BloodHound (install on a client machine with Neo4j database).
- SharpHound collector (download from BloodHound GitHub).
- A domain with some objects: create a few users, groups, and delegation for realism.
🛠️ Step 1: Run SharpHound Collector
- On a domain‑joined client, run SharpHound.exe as a domain user (not admin needed):
SharpHound.exe --CollectionMethods All --Domain lab.contoso.com --OutputDirectory C:\BloodHound
- This will create a ZIP file with the collected data.
🛠️ Step 2: Import into BloodHound
- Start Neo4j database and BloodHound GUI.
- Log in to BloodHound (default credentials: neo4j / neo4j).
- Click “Upload Data” and select the ZIP file.
🛠️ Step 3: Analyze Attack Paths
- Use the pre‑built queries:
- “Find all Domain Admins”: See who has DA rights.
- “Shortest Paths to Domain Admins from Owned Principals”: If you mark a user as “owned”, BloodHound will show paths to DA. Mark a low‑privileged user as owned (right‑click → Mark User as Owned).
- “Find Computers with Unconstrained Delegation”: Identify high‑risk computers.
- “Find Kerberoastable Users”: List accounts with SPNs.
- Explore the graph. For example, you might find that a low‑privileged user has
GenericAllrights on a group that is a member of Domain Admins – a clear attack path.
🛠️ Step 4: Remediate Findings
Based on your findings, take corrective actions:
- Remove unnecessary permissions (e.g.,
GenericAllon privileged groups). - Disable unconstrained delegation on computers.
- Ensure Kerberoastable accounts have strong passwords or use gMSAs.
🛠️ Step 5: Re‑run BloodHound
After remediation, re‑run SharpHound and re‑import to verify that the attack paths are removed.
18.7 Deploying Microsoft Defender for Identity
🎯 Lab Objective
Deploy Microsoft Defender for Identity (formerly Azure ATP) to monitor your AD environment for suspicious activities. This lab uses a trial Azure subscription.
📋 Prerequisites
- An Azure subscription with Global Admin rights.
- A domain controller in your lab with internet access (to communicate with Defender for Identity cloud).
🛠️ Step 1: Set up Defender for Identity in Azure
- Go to the Microsoft 365 Defender portal (security.microsoft.com).
- Navigate to Settings → Identities.
- Click Create new workspace (or use existing). Provide a name and region.
- Download the sensor setup package and obtain the access key.
🛠️ Step 2: Install the Sensor on Domain Controller
- On your lab DC, run the downloaded sensor installer as administrator.
- Accept the license terms and enter the access key when prompted.
- During installation, you can choose to install the sensor for domain controllers only.
- After installation, the sensor will start and connect to the cloud.
🛠️ Step 3: Verify Installation
- In the Microsoft 365 Defender portal, go to Identities → Sensors. You should see your DC listed as healthy.
- It may take a few minutes for the first data to appear.
🛠️ Step 4: Simulate an Attack
To test detection, simulate a known attack pattern. For example, perform a DCSync attack using Mimikatz (in a lab only!).
- On a domain‑joined machine (not the DC), run Mimikatz as administrator:
lsadump::dcsync /domain:lab.contoso.com /user:krbtgt
- Within minutes, Defender for Identity should generate an alert for “Suspicious DCSync activity”.
- Check the alert in the portal, view the timeline, and investigate.
🛠️ Step 5: Configure Health Alerts and Reports
Set up email notifications for health issues and suspicious activities. Explore the dashboard to see identity risk scores and lateral movement paths.
18.8 Migrating Active Directory to Azure using Azure Migrate
🎯 Lab Objective
This lab simulates migrating on‑premises Active Directory domain controllers to Azure Infrastructure as a Service (IaaS). You will use Azure Migrate to assess and migrate a DC VM.
📋 Prerequisites
- An Azure subscription.
- A Hyper‑V or VMware VM running a domain controller (from previous labs).
- Azure Migrate appliance set up in your on‑prem environment.
🛠️ Step 1: Assess with Azure Migrate
- In Azure portal, create a new Azure Migrate project.
- Deploy the Azure Migrate appliance (OVA for VMware or script for Hyper‑V) on your on‑prem host.
- Add the DC VM for assessment. Wait for discovery to complete.
- Review the assessment report to ensure the VM is suitable for Azure (disk performance, OS support).
🛠️ Step 2: Prepare for Migration
- Ensure the DC is backed up.
- Note the FSMO roles – if this is the only DC, you may need to transfer roles after migration. Ideally, you have at least two DCs, so you can migrate one and keep one on‑prem temporarily.
- Plan networking: Create a virtual network in Azure with VPN or ExpressRoute connectivity to on‑prem. For lab, you can use a site‑to‑site VPN.
🛠️ Step 3: Replicate the VM to Azure
- In Azure Migrate, go to “Servers, databases and web apps” and select the DC VM.
- Click “Replicate” and configure target settings (subscription, resource group, virtual network, storage).
- Start replication. Initial replication may take time depending on VM size and network.
🛠️ Step 4: Test Migration
- After initial replication completes, you can run a test migration to a non‑production VNet.
- Start the test VM in Azure, verify it boots, and check that it can communicate with on‑prem DCs.
- Do not promote this test VM to production – it's a test.
🛠️ Step 5: Migrate (Cutover)
- Shut down the on‑prem DC (to avoid conflicts).
- In Azure Migrate, complete the migration – the Azure VM will be started.
- Log in to the Azure DC and verify it is functioning. Ensure it has the same name and IP (if possible) or update DNS accordingly.
- If you migrated the only DC, you may need to seize FSMO roles (but better to have at least two DCs).
18.9 Custom AD Reports via PowerShell
🎯 Lab Objective
Create custom reports using PowerShell to export AD data for auditing, compliance, and operational needs. You will generate reports on users, groups, computers, and password status.
📋 Prerequisites
- Domain with typical objects.
- PowerShell with ActiveDirectory module installed.
🛠️ Step 1: Export All Users with Specific Attributes
Get-ADUser -Filter * -Properties Department, Title, Manager, LastLogonDate, PasswordLastSet, PasswordExpired, Enabled |
Select-Object Name, SamAccountName, UserPrincipalName, Department, Title, @{Name='Manager';Expression={$_.Manager -replace '^CN=([^,]+),.*','$1'}}, LastLogonDate, PasswordLastSet, PasswordExpired, Enabled |
Export-Csv "C:\Reports\AllUsers.csv" -NoTypeInformation
🛠️ Step 2: Report on Inactive Users (Not Logged On for 90 Days)
$cutoff = (Get-Date).AddDays(-90)
Get-ADUser -Filter "LastLogonDate -lt '$cutoff' -and Enabled -eq 'True'" -Properties LastLogonDate |
Select-Object Name, SamAccountName, LastLogonDate |
Export-Csv "C:\Reports\InactiveUsers.csv" -NoTypeInformation
🛠️ Step 3: Report on Group Memberships (All Groups, All Members)
This script exports all groups and their members recursively.
$groups = Get-ADGroup -Filter *
$report = @()
foreach ($group in $groups) {
$members = Get-ADGroupMember -Identity $group -Recursive | Get-ADUser -Properties Name, SamAccountName
foreach ($member in $members) {
$report += [PSCustomObject]@{
GroupName = $group.Name
GroupSamAccountName = $group.SamAccountName
MemberName = $member.Name
MemberSamAccountName = $member.SamAccountName
}
}
}
$report | Export-Csv "C:\Reports\AllGroupMemberships.csv" -NoTypeInformation
🛠️ Step 4: Report on Computers with Last Logon Date
Get-ADComputer -Filter * -Properties LastLogonDate, OperatingSystem |
Select-Object Name, OperatingSystem, LastLogonDate |
Export-Csv "C:\Reports\Computers.csv" -NoTypeInformation
🛠️ Step 5: Scheduled Reporting
To automate these reports, create a PowerShell script and schedule it with Task Scheduler. For example, run weekly and email the reports to a distribution list.
# Send email example
Send-MailMessage -To "reports@contoso.com" -From "adreports@contoso.com" -Subject "Weekly AD Report" -Body "Attached." -Attachments "C:\Reports\AllUsers.csv" -SmtpServer smtp.contoso.com
18.10 Real‑World Incident Response Simulation
🎯 Lab Objective
Simulate a real‑world Active Directory security incident (e.g., Golden Ticket compromise) and practice the incident response process from detection to remediation.
📋 Prerequisites
- Multi‑site lab with at least two DCs.
- Tools: Mimikatz (for simulation), SIEM or logging configured.
- A documented incident response plan (create a simplified one for lab).
🛠️ Step 1: Simulate an Attack (Golden Ticket Creation)
On a compromised machine (e.g., a domain‑joined workstation), run Mimikatz with domain admin privileges to forge a Golden Ticket.
# Extract KRBTGT hash (requires DA)
lsadump::dcsync /domain:lab.contoso.com /user:krbtgt
# Forge Golden Ticket for a fake admin
kerberos::golden /user:EvilAdmin /domain:lab.contoso.com /sid:S-1-5-21-... /krbtgt:hash /id:500 /groups:512 /ptt
🛠️ Step 2: Detection
In a real incident, detection might come from:
- Security alerts (Microsoft Defender for Identity, SIEM).
- Anomalous logon events (Event ID 4768 with long lifetime).
- Users reporting unexpected access.
For this lab, you will manually check for signs:
- On a DC, search for Event ID 4768 with a lifetime > 10 hours.
- Look for logons from the forged account “EvilAdmin”.
🛠️ Step 3: Containment
- Isolate the compromised machine from the network (disable its network adapter).
- Reset the KRBTGT password twice (with a 10‑hour interval in real life; for lab, you can simulate). This invalidates the Golden Ticket.
- Reset passwords of any accounts that may have been compromised.
🛠️ Step 4: Eradication
- Check for other backdoors: new user accounts, group changes, unexpected services.
- Remove the forged ticket from the compromised machine (if accessible).
- Patch the vulnerability that led to initial compromise.
🛠️ Step 5: Recovery
- Restore any affected data from backups.
- Verify that the KRBTGT password change has replicated.
- Bring systems back online.
🛠️ Step 6: Lessons Learned
Document the incident, what worked, what didn't. Update your incident response plan and security controls.
Regular incident response drills are essential. They prepare your team for real‑world attacks and help improve your security posture.
🎓 Module 18 : Hands-On Labs & Scenarios Successfully Completed
You have successfully completed this module of Active Directory For Beginners.
This module provided practical, hands‑on experience with real‑world Active Directory scenarios. You have built, broken, fixed, and secured AD environments, gaining skills that are directly applicable in production.
Congratulations on completing all 18 modules! You have mastered Active Directory from fundamentals to advanced security, architecture, and hands‑on troubleshooting.