Active Directory Architecture and Management Questions
Designing, operating and recovering Active Directory Domain Services and the directory estate around it. Covers logical and physical structure (forests, trees, domains, OUs, trusts, schema extension, FSMO roles, Global Catalog, RODCs), sites and replication topology, domain controller placement, promotion, upgrade and functional levels, DC locator and AD-integrated DNS, domain join, Kerberos and NTLM authentication including SPNs and delegation, token size and SID history, LDAP binds and query tuning, Group Policy design, processing order, filtering, deployment and troubleshooting, user, group, computer and service account management including PowerShell account scripting and account lockout investigation, delegation of control and tiered administration, fine-grained password policy, backup, authoritative restore, forest recovery and USN rollback, AD hardening against Kerberoasting, DCSync and Golden Ticket attacks, forest migration, and hybrid identity with Microsoft Entra ID (Microsoft Entra Connect, Cloud Sync, password hash sync, pass-through authentication, federation, password writeback). Questions are asked from the directory administrator's and architect's seat. Platform-neutral identity protocols and lifecycle design, Windows file-server administration (shares, NTFS permissions, profiles), Linux directory integration, and generic DNS and DHCP service operations are covered elsewhere.
Design a backup and disaster recovery plan for a five-domain forest with a one-hour RPO and an eight-hour RTO. Say how you would test it.
Sample Answer
Direct answer
Use layers, because one mechanism cannot meet both targets. Replication across several domain controllers (DCs) per domain covers losing a DC or a site, with a recovery point (RPO) of roughly the last replication. Hourly system state backups of one designated writable DC per domain, plus nightly backups of a second one, cover logical corruption and forest-wide failure (a system state backup is the set that includes the AD database, SYSVOL and the registry), with the one-hour RPO applying only if the failure time is known. A written, practiced forest recovery plan covers the eight-hour recovery time (RTO). RPO is how much data you can lose; RTO is how long recovery may take.
Design
Layer 1: replication. Two or more writable DCs per domain in each hub, so an ordinary DC failure costs no data beyond changes not yet replicated.
Layer 2: backups.
| What | Frequency | Count per day (5 domains) | Notes |
|---|---|---|---|
| System state backup of the designated restore DC in each domain | Hourly | 5 x 24 = 120 | A dedicated restore DC per domain (one DC chosen in advance as the one you would restore) makes recovery repeatable and scriptable. |
| System state backup of a second writable DC per domain (include the PDC emulator, the role whose SYSVOL copy is usually best) | Nightly | 5 | At least two writable DCs per domain should be backed up so there are choices. |
| Full server backup of the restore DC | Weekly | 5 per week | Needed to rebuild onto different hardware: a system state backup cannot be restored onto a fresh install. |
ntdsutil snapshot of the database | Hourly, kept 24 hours | 120 | ntdsutil snapshot makes a point-in-time copy of the AD database volume; dsamain mounts such a copy as a read-only directory you can query, to find the last safe state without restarting a DC in DSRM (Directory Services Restore Mode, the offline repair boot mode). |
That is 125 system state backup runs a day, plus the snapshots and the weekly full backup. System state is taken with wbadmin start systemstatebackup -backuptarget:<drive>: or a backup product that uses the AD-aware Volume Shadow Copy Service writer (the AD component that makes the database files consistent while they are copied). Layers 1 to 3 are what the targets require; the snapshot row, DC cloning and immutable offsite copies shorten recovery or protect the backups. Measure the load of hourly runs in the drill before committing to it.
Offsite and local copies. Keep a local copy for speed and an offsite or immutable copy for survival. Retention for any backup must stay inside the tombstone lifetime (the period deleted-object records are kept), or the deleted-object lifetime if the AD Recycle Bin is on, whichever is smaller. A backup older than that cannot safely be restored. Also store, offline and with the backup: Domain Admin and DSRM passwords and BitLocker recovery keys.
Layer 3: recovery plan. A topology table of every DC (name, OS, FSMO roles, global catalog (GC) status, RODC status, backup, DNS, virtual or not; FSMO means Flexible Single Master Operations, the five single-holder roles), a chosen restore DC per domain, and a recovery order: forest root domain first, one DC per domain restored in isolation, cleaned, reconnected; the remaining DCs then redeployed (virtual DC cloning speeds this up). Root first because it holds the forest-wide roles (schema master, domain naming master) and the other domains find it for DNS and trusts. In isolation means the restored DC is kept off the network of the other DCs, so it cannot replicate with a DC that still holds the corruption or the attacker's changes, and other DCs cannot overwrite it. Cleaned means removing the directory records of the DCs you are not restoring (metadata cleanup, because those servers will be rebuilt later) and taking over any FSMO role it lacks (seizing a role means claiming it without the old holder's cooperation, unlike a transfer, because the old holder is gone). Reconnected means bringing it back onto the network once those steps are done. RODC (read-only domain controller) backups cannot be used to restore a writable DC.
What the RPO really means
One hour is achievable when a DC, a site, or a whole domain is lost but some DC still holds recent data, and when a bad change is noticed fast and the last hourly backup is clean. It is not achievable when the failure is a compromise or corruption of unknown start time. Microsoft's guidance is to restore from a backup taken a few days before the failure, trading recent data for safety from reintroducing the bad data. So the answer to the business is two numbers: RPO of about an hour for known-time accidents, and RPO equal to the chosen safe restore point for malicious or unknown-time events. Say that explicitly rather than promising one hour for everything.
RTO budget
These are planning allowances to be replaced by timings measured in the drill, not measurements.
| Step | What happens | Hours |
|---|---|---|
| Decide, declare, isolate all writable DCs | Incident lead decides it is a forest recovery; every writable DC is taken off the network so nothing replicates | 1.0 |
| Restore first DC in the root domain, clean it | Restore the system state onto the root domain's restore DC, delete the metadata of the other DCs, seize the roles, reset the krbtgt password the first time; if the restored DC was a global catalog, clear that flag (Microsoft's guide does this for a restored global catalog in a multi-domain forest) | 2.0 |
| Restore one DC in each of the other 4 domains, in parallel | Same restore and cleaning for each domain, by separate people at the same time; the forest has several domains, so clear the global catalog flag on each restored DC (Microsoft's forest recovery guide warns that a restored global catalog from a more recent backup than another domain's can introduce lingering objects) | 2.0 |
| Validation (replication, DNS, trusts, global catalog, test logons) | Reconnect the restored DCs on an isolated common network, check DNS, trusts, replication and a test logon in each domain, then add the global catalog to a root-domain DC (Microsoft's guide adds it only after the restored DCs are reconnected and replication is checked; user logons need a global catalog) | 1.5 |
| Redeploy the minimum extra DCs for load | Promote or clone more DCs so that logon capacity is enough | 1.0 |
| Total | 7.5, leaving 0.5 hour of margin |
One step cannot fit in any 8-hour window: the krbtgt account (the account whose key signs all Kerberos tickets) must be reset twice, at least 10 hours apart by default, so the second reset lands roughly 10 hours after the first. The reason, from Microsoft's forest recovery guide: 10 hours is the default maximum lifetime of a user ticket and of a service ticket, and krbtgt remembers its two most recent passwords. Two resets clear the old password from that history, but if the second came sooner, clients still holding tickets signed with the old key would be rejected. Microsoft's forest recovery guide lists the krbtgt reset among the initial steps on the first restored DC of each domain, so in this plan the first reset lands at about hour 3.0 in the root domain and hour 5.0 in the other four, which puts the second resets at about hour 13.0 and hour 15.0 (deferring the first reset to the end of validation, hour 6.5, would push the second to hour 16.5). Every variant falls outside the 8-hour window. Define the RTO as "directory usable by users" and treat the second reset as scheduled post-recovery work, which is my reading of the documented 10-hour minimum.
How to test it
- Run a full forest recovery drill at least once a year, and again when membership of Enterprise Admins or Domain Admins changes, so the people who would execute it have done it.
- Restore the real offsite copies onto an isolated virtual network, not the local convenience copy.
- Time each step against the table above. Record the age of the backup used. Pass means users can log on and DNS resolves within 8 hours, and the age of the data restored is within the stated RPO for that scenario.
- Include an authoritative SYSVOL step (making the restored DC's SYSVOL the source copy that the other DCs then copy from), the password and key inventory, and a restore of a single deleted object.
The same design for a mid-size single-domain estate
A mid-size organisation with one domain and a handful of DCs uses the same layers with fewer moving parts: hourly backup of the restore DC (24 per day) plus one nightly backup of a second DC (25 per day), and the recovery path loses the "other domains in parallel" step, so the 2.0 hours for that row drops out and the budget total is 5.5 hours.
Pitfalls
- Backups never restored, so the first test is the real event.
- Restoring a backup older than the tombstone lifetime.
- Restoring from a snapshot as a substitute for a backup.
- Restoring an FSMO holder "for simplicity" instead of restoring a plain DC and seizing the roles.
Users intermittently fail to authenticate to applications across two trusted forests, and the apps use delegation. How would you troubleshoot?
Sample Answer
Direct answer
Terms used here: Kerberos is the ticket-based sign-in protocol. A ticket-granting ticket (TGT) is what a user receives at sign-in. A service ticket is what the key distribution center (KDC, the Kerberos service on every DC) issues for one service, which is named by its service principal name (SPN). Delegation lets a front-end service call a back-end service as the user rather than as itself. Example (names illustrative): users sign in to an intranet site on web01, which runs as CONTOSO\svc-web; the site then queries a database on sql01 in the fabrikam.example forest and must do so as the signed-in user, so the database applies that user's permissions. Classic constrained delegation keeps the list of back-end SPNs svc-web may delegate to on the svc-web account. Resource-based constrained delegation keeps, on the sql01 account, the list of front-end accounts allowed to delegate to it. Unconstrained delegation lets a front end act as the user toward any service, which is why it is avoided. Protected Users is a built-in group whose members' credentials cannot be delegated. A referral TGT is a ticket for the other forest's realm that the client's own DC issues so the client can talk to a DC there. Name suffix routing is the forest-trust setting that says which DNS suffixes each forest owns, so a DC knows where to send a request for a name. The PAC (privilege attribute certificate) is the part of a ticket that carries the user's group memberships.
"Intermittent" means the failure depends on something that changes between attempts: which domain controller (DC) answers, which user signs in, which back-end server is hit, or how old or large a ticket is. Find that variable first by reading the Kerberos error code on the DC that handled a failing request, then work outward in a fixed order: error code, trust health, DC and DNS selection, clock skew, and last the delegation settings. With delegation, check two structural causes early. Classic constrained delegation (configured on the front-end service account) is restricted to a single domain, so a front end and back end in different domains need resource-based constrained delegation (configured on the back end). Microsoft's constrained delegation overview documents resource-based delegation for a front end and back end in different domains; it does not describe the forest-trust case, so prove the cross-forest path in a lab before depending on it. And users who are in the Protected Users group, or flagged "Account is sensitive and cannot be delegated", cannot be delegated by design, which looks intermittent to the app owner because only those users fail.
How a cross-forest request travels
- The client asks a DC in its own forest for a service ticket for the SPN.
- That DC checks the global catalog, finds that the SPN is not in its forest, and returns a referral toward the other forest. Name suffix routing on the forest trust decides which forest owns a name, so a disabled or conflicting suffix stops the referral.
- The client follows the referral chain until it reaches a DC in the forest that owns the SPN, and that DC issues the service ticket.
Every DC along that path, in both forests, can be the broken hop. One unhealthy DC therefore produces a "sometimes" failure.
Ordered checks
1. Reproduce from a client and record which DC answered. Run klist get http/app01.fabrikam.example (substitute the real SPN). klist tickets shows the referral TGT and the service ticket that were obtained, and klist tgt shows a TimeSkew field (the clock difference with the KDC). Run it repeatedly and note the answering DC with nltest /dsgetdc:fabrikam.example /KDC /force. Failures that always follow one DC point at that DC. Failures that follow one user point at delegation protections. Failures that follow one back-end server point at that server's SPN or permissions.
Illustrative klist tickets output (abridged, not captured from a live forest), for a client in contoso.example reaching app01 in fabrikam.example:
#0> Client: asmith @ CONTOSO.EXAMPLE
Server: krbtgt/FABRIKAM.EXAMPLE @ CONTOSO.EXAMPLE
KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
#1> Client: asmith @ CONTOSO.EXAMPLE
Server: http/app01.fabrikam.example @ FABRIKAM.EXAMPLE
KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
Ticket #0 is the referral TGT (the contoso DC sent the client toward fabrikam) and ticket #1 is the service ticket issued by a fabrikam DC. If only #0 appears, the request died on the fabrikam side of the path. Illustrative nltest /dsgetdc output (abridged):
DC: \\dc02.fabrikam.example
Address: \\10.20.0.12
Forest Name: fabrikam.example
Dc Site Name: Dallas
Our Site Name: Chicago
Flags: GC DS LDAP KDC TIMESERV WRITABLE DNS_DC DNS_DOMAIN DNS_FOREST
The command completed successfully
The DC line is the controller that answered, and KDC in Flags confirms that DC issues Kerberos tickets. For a domain in the client's own forest, different Dc Site Name and Our Site Name values mean the client is using a controller in another site. Across a forest trust the two site names come from two separate site topologies and need not match, so the signal to follow is the DC line changing between attempts, with the site names as context only. Repeat the command and compare: a different DC each time is the hidden variable. Checks 1, 2 and 5 are the quick ones (a client run, an event log read, a clock reading) and usually show whether trust, DNS or delegation work is needed at all.
2. Read the failure code on the DC. Event 4769 (a Kerberos service ticket was requested) logs a Failure Code, but only if the Audit Kerberos Service Ticket Operations subcategory is enabled.
| Code | Name | What it usually means | Next action |
|---|---|---|---|
| 0x25 | KRB_AP_ERR_SKEW | Clock difference beyond the allowed tolerance | Fix time sync (check 5) |
| 0x7 | KDC_ERR_S_PRINCIPAL_UNKNOWN | The DC cannot find the server name | Check the SPN and the trust's name suffix routing |
| 0x8 | KDC_ERR_PRINCIPAL_NOT_UNIQUE | Duplicate principal names | Find and remove the duplicate SPN |
| 0xD | KDC_ERR_BADOPTION | Delegation target is not in the account's allowed-to-delegate list | Check the delegation configuration (check 6) |
| 0xE | KDC_ERR_ETYPE_NOTSUPP | No common encryption type | Compare encryption types on client, service and DC |
| 0x3C | KRB_ERR_GENERIC | Includes a PAC overloaded by group membership, or an SPN that is too long | Count the user's groups, check the SPN length |
| 0x44 | KDC_ERR_WRONG_REALM | A cross-realm TGT was presented to the wrong realm, typically bad DNS | Check DNS forwarding between the forests |
Check 0x25 and 0x7 first: each takes one command to confirm (a clock reading, an SPN lookup), and the other codes need more digging once those are ruled out. Code 0x34 (response too big) is informational: Windows retries over TCP automatically. One caveat on the table: Microsoft's event 4769 reference says some errors are only logged when the KdcExtraLogLevel registry value on the DC enables them. Flag 0x01 audits SPN-unknown errors (0x7), and flag 0x10 audits encryption-type and bad-option errors (0xE and 0xD). If a DC shows no 0x7, 0xD or 0xE although you suspect them, check that value before concluding they are absent.
3. Test the trust itself, from both sides.
nltest /domain_trusts /vlists the trusts, andnltest /sc_query:fabrikam.examplereports the secure channel state.- On a workstation,
netdom trust contoso.example /domain:fabrikam.example /verify /kerberoschecks Kerberos across the trust (it needs credentials for both domains and cannot be run remotely). netdom trust contoso.example /domain:fabrikam.example /namesuffixeslists the routed name suffixes, andnltest /dsgetfti:fabrikam.example, run on a DC in the forest root, returns forest trust information.
4. Check DC location and DNS. Repeat nltest /dsgetdc and compare answers. Different DCs on different attempts, or a DC in a distant site, show a DNS or site problem. Every DNS server that clients use must carry the same conditional forwarder for the other forest.
5. Check time. Kerberos tolerates 5 minutes of difference by default (Maximum tolerance for computer clock synchronization, Default Domain Policy). Windows Time follows the domain hierarchy: in a forest, the PDC emulator of the forest root domain is the best time source unless another reliable source is configured, and Microsoft's Windows Time documentation says the authoritative computer for the domain must be configured to synchronize with an external time source rather than with the domain hierarchy. A DC with a wrong clock therefore usually has a wrong source higher up that chain.
6. Check the delegation configuration.
- Classic delegation stores the allowed back-end SPNs on the front-end account, and Microsoft documents it as restricted to a single domain. Resource-based delegation stores the allowed front-end accounts on the back-end account:
Get-ADComputer backend01 -Properties PrincipalsAllowedToDelegateToAccountshows it, andSet-ADComputer -PrincipalsAllowedToDelegateToAccountsets it. It moves the decision to the owner of the back end. The overview documents this for a front end in another domain; for a front end in the other forest, confirm it with a real delegated call before relying on it. - On the front end,
klist kcd_cacheshows the last constrained delegation error. On the DC, the Transited Services field of event 4769 lists the SPNs requested through constrained delegation, that is, the services that acted on the user's behalf. - Protected Users members cannot delegate with unconstrained or constrained delegation. List them with
Get-ADGroupMember 'Protected Users'. - If the trust uses selective authentication, each user or group needs the Allowed to Authenticate permission on every resource computer object. A back-end server that lacks it fails for everyone from the other forest.
7. Fix one thing, then prove it. After the change run klist purge (it deletes every cached ticket for the session) and klist get <SPN> about 20 times from clients in each site. Watch event 4769 on all DCs for Failure Code 0x0.
Worked example
Pilot of an app in the fabrikam.example forest used by 40 contoso.example users. Two symptoms appear.
- Failures only from one branch.
klist tgtshows a TimeSkew of 7 minutes 12 seconds, which is 432 seconds against a 300 second tolerance, 132 seconds over. Event 4769 shows 0x25. The branch DC's time source was wrong. Fix the source; do not widen the tolerance. - Failures for 3 of the 40 users (7.5 percent), on random days. All three are in Protected Users because they are administrators, so the app cannot delegate their identity. Decision: those accounts do not use the delegated app, and administrators use separate non-protected accounts for it.
Trade-offs and pitfalls
- Do not raise the clock tolerance. It exists to limit ticket replay.
- Do not enable full (unconstrained) delegation across the trust.
netdom trust ... /EnableTgtDelegation:Noblocks Kerberos full delegation on an outbound forest trust, and that block should stay. - Do not switch selective authentication off to test. Grant Allowed to Authenticate on the specific resource computers instead.
- Reset the trust secret (
netdom trust ... /reset) only when/verifyfails, because it changes both sides. - Change one thing at a time and purge tickets between tests.
What flips the diagnosis: if every failure follows one DC, repair that DC (DNS registration, time, replication) and leave the trust alone. If a front end and back end must live in different forests permanently, weigh moving the front end into the back end's forest against maintaining cross-forest delegation.
What is Active Directory, and what problems does it solve for an organisation that has hundreds of users and servers?
Sample Answer
Direct answer
Active Directory (AD) here means Active Directory Domain Services (AD DS): a replicated directory database of objects (user accounts, computers, groups) together with the services that authenticate those objects and apply policy to them. For an organisation with hundreds of users and servers it replaces a separate list of accounts on every machine with one shared identity store. That gives one account per person, one sign-in, central access control through groups, central configuration through Group Policy (settings such as a password rule or mapped drive that Windows applies automatically to the users and computers they are linked to), and a directory that keeps working when one server fails because every domain controller (DC, a server that holds a copy of the directory and answers sign-in requests) carries a full copy of its domain's data.
What AD DS contains
| Piece | What it does |
|---|---|
| Directory data store | Holds the objects: users, computers, groups, printers, organisational units (OUs, containers used for delegation and policy) |
| Schema | The rules that define which classes of object and attributes may exist |
| Domain controllers and replication | Every DC in a domain holds a complete copy of that domain's data, and a change made on any DC is replicated to the others |
| Global catalog (GC) | A searchable index of every object in the forest with a small set of attributes, so you can find an object without knowing which domain holds it |
| Search and publish service | Lets people and applications publish objects into the directory and search for them, for example finding a printer by location |
Problems it solves at this size
- Identity sprawl. Without a directory, each of 40 servers keeps its own local accounts. For 300 users that is up to 300 x 40 = 12,000 account entries to create, reset and delete by hand. With AD there are 300 accounts, created once.
- Authentication. A user proves who they are once, at sign-in, and then reaches file shares, printers and intranet sites without being asked again (single sign-on). The Kerberos Key Distribution Center (KDC, the service that issues tickets) runs on every DC and uses the AD DS database as its account store.
- Authorisation. Access control lists (ACLs, the per-resource lists of who may do what) name groups rather than individuals, so moving someone between teams is one group change.
- Configuration. Group Policy settings are linked to OUs and apply to the users and computers in them, so a password-length rule or a mapped drive is defined once.
- Delegation. Control of an OU can be given to a help-desk group, so they can reset passwords for one department without holding rights over the whole domain.
- Resilience. AD DS is multimaster (every DC accepts changes, rather than one primary server and read-only copies): a change can be made at any DC and is replicated to the rest, so losing one DC does not stop sign-in.
The three things it depends on
An SRV record names a service, a port and the host that provides it. A DC registers one such as _ldap._tcp.dc._msdcs.corp.contoso.com SRV 0 100 389 dc01.corp.contoso.com, which reads: the LDAP service of domain controllers in corp.contoso.com is on port 389 of dc01. A client that wants to sign in asks DNS for that record before it can talk to any DC. Illustrative check from a client with nslookup -type=SRV _ldap._tcp.dc._msdcs.corp.contoso.com:
_ldap._tcp.dc._msdcs.corp.contoso.com SRV service location:
priority = 0
weight = 100
port = 389
svr hostname = dc01.corp.contoso.com
dc01.corp.contoso.com internet address = 10.0.0.10
Read-out: the svr hostname line is the DC the client would contact, and the port line is LDAP. When DNS is the broken part, that lookup returns an error such as a non-existent domain, or times out, even though every DC is running. That is the shape of "servers healthy, sign-in broken": the clients never learn where a DC is.
| Dependency | Role | Failure shape |
|---|---|---|
| DNS | DCs register service (SRV) records, DNS entries that say which host offers a given service on which port; clients query DNS to find a DC | Servers are healthy but clients cannot find any DC, so sign-in is slow or fails |
| LDAP (Lightweight Directory Access Protocol) | The protocol clients and tools use to read and write directory data (TCP and UDP 389, LDAP over SSL 636, global catalog 3268 and 3269) | Directory lookups and discovery pings fail |
| Kerberos | Ticket-based authentication: the client proves its identity once to a DC and receives a time-limited ticket that other servers accept instead of a password; port 88 | Tickets rejected when the client clock differs from the DC clock by more than the default 5 minutes |
Worked example
A 300-person company with 40 servers and two offices has two DCs in the head office and one in the branch. On a new hire's first day the administrator creates one account, places it in the OU for Finance, and adds it to the group Finance-Share-Modify. That one change gives access to the finance file share, picks up the Finance OU's Group Policy, and works on any of the 40 servers.
When someone leaves, the administrator disables the one account. A Kerberos ticket-granting ticket (TGT, the ticket a user gets at sign-in) has a default maximum lifetime of 10 hours, so a person who signed in at 08:00 may keep working with tickets already issued until about 18:00. The disable stops the account signing in again, but tickets already issued stay valid until they expire (Microsoft's Kerberos policy documentation notes that users whose accounts were disabled can keep using valid tickets issued before the disable), so an urgent case also needs the user's sessions on the servers ended.
Trade-offs and pitfalls
- A single DC is a single point of failure: keep at least two per domain so one can be patched or lost without stopping sign-in.
- Most "AD is broken" reports are really DNS or clock problems. Check name resolution and time first.
- AD stores identity and policy, not bulk business data: every object in a domain is replicated to every DC of that domain, so what you put there is paid for everywhere.
- Disabling an account is not instant revocation: existing tickets outlive it for up to their lifetime.
Sales users need a mapped network drive to the sales file share, a logon-time compliance script, and a locked-down user registry setting, all through Group Policy. How would you build the policy, limit it to the right people and machines, and test it before wide rollout?
Sample Answer
Direct answer
Put three things in one Group Policy Object (GPO, a bundle of settings applied to users or computers): a Group Policy Preferences drive map (a mapped drive that users may still change), a logon script under User Configuration, and a registry-based policy setting (enforced, so users cannot undo it). Link it first to a small pilot organizational unit (OU, a container for users and computers), scope it with security filtering (who receives the whole GPO) plus item-level targeting (who receives one preference item), prove it with gpresult and Group Policy Modeling, then widen the link.
Build
| Need | Where it lives | Notes |
|---|---|---|
| Mapped drive to the sales share | User Configuration, Preferences, Windows Settings, Drive Maps | Action Update (changes only the settings you define and creates the drive if missing; Replace deletes and recreates it). Location is a UNC path (a network path to a share) such as \\fs01\Sales. Tick Reconnect to restore the drive at each logon. Drive Maps run in the user's security context by default. |
| Compliance script at logon | User Configuration, Policies, Windows Settings, Scripts (Logon) | Scripts run only when a user logs on or off, never at the 90-minute background refresh. For something that must re-run on a schedule use the Scheduled Tasks preference extension (creates scheduled or immediate tasks). |
| Locked-down registry setting | User Configuration, Administrative Templates if a setting exists, otherwise a registry-based policy | Policy is enforced; a preference is not and can be changed by the user. Example from the cmdlet documentation: screen saver timeout 900 seconds. |
New-GPO -Name 'Sales - User Environment' |
New-GPLink -Target 'OU=Sales Pilot,OU=Staff,DC=corp,DC=contoso,DC=com' -LinkEnabled Yes
Set-GPRegistryValue -Name 'Sales - User Environment' `
-Key 'HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop' `
-ValueName 'ScreenSaveTimeOut' -Value 900 -Type DWord
Set-GPPermission -Name 'Sales - User Environment' -TargetName 'Sales-Users' `
-TargetType Group -PermissionLevel GpoApply
# Downgrade the default entry from Read + Apply to Read only (do not delete it)
Set-GPPermission -Name 'Sales - User Environment' -TargetName 'Authenticated Users' `
-TargetType Group -PermissionLevel GpoRead -Replace
The hive in -Key decides the side: HKCU lands in User Configuration. Drive map and logon script are added in the Group Policy Management Console (GPMC) editor. The last command narrows the default security filtering so that only Sales-Users applies the GPO. It keeps Read for Authenticated Users on purpose: since the MS16-072 security update, user policy is retrieved using the computer's security context, so Microsoft's guidance is to give Authenticated Users (or, when you filter, Domain Computers) Read permission on the GPO. Removing the entry on the GPO's Scope tab instead leaves computer accounts unable to read it, and user settings can then fail to apply even for Sales-Users. Confirm with Get-GPPermission -Name 'Sales - User Environment' -All: Sales-Users should show GpoApply and Authenticated Users GpoRead.
Click path in the Group Policy Management Console (GPMC): under Group Policy Objects, right-click the GPO and choose Edit. For the drive, expand User Configuration, Preferences, Windows Settings, then right-click Drive Maps, New, Mapped Drive. Set Action to Update, Location to \\fs01\Sales, a drive letter such as S:, tick Reconnect, and use the Common tab for item-level targeting. For the script, go to User Configuration, Policies, Windows Settings, Scripts (Logon/Logoff), double-click Logon and use Add to point at the script.
Scoping: people and machines
- User settings follow the user object, so link where the Sales users live. A GPO applies to every user in that OU unless filtered.
- Security filtering works on the whole GPO and cannot be used selectively on different settings inside it.
- Item-level targeting works per preference item and is evaluated on the client by the preference extension. Each targeting item evaluates to true or false, and several can be combined with AND or OR. Put a Security Group targeting item on the drive map (it applies when the user or computer is a member of the named group) and, if the drive must appear only on office PCs, add an Organizational Unit targeting item for the computer's OU, or a Site or IP Address Range item (the name Microsoft's documentation gives the IP range check; that item does not support IPv6 addresses).
- To limit by machine type, link one WMI filter (a Windows Management Instrumentation (WMI) query evaluated on the destination computer; the GPO applies only if it returns true) to the GPO. A GPO can hold one WMI filter.
Test before wide rollout
- Back up the GPO:
Backup-GPO -Name 'Sales - User Environment' -Path \\fs01\gpbackup. - Pilot OU with two test users and one workstation. Run
gpupdate /forceon the client, then log off and on so logon-time items run. - Prove it:
gpresult /h pilot.html(the GPO must appear as applied),net usefor the drive, check the log written by the script, and read the registry value. - Preview other populations without logging in as them using Group Policy Modeling in GPMC. Modeling is a wizard that simulates what would apply to a chosen user and computer location and reports the GPOs and settings that would win. It reads no client, so it answers "what if Raj moved into the Sales OU" before anyone is moved, while
gpresultreports what a client actually applied. - Widen: relink to the Sales OU with the
Sales-Usersfilter; unlink is the rollback for policy settings. A preference needs its own reverse item (for the drive: action Delete).
Worked example
The pilot OU holds two test users: Ann, a member of Sales-Users, and Raj, who is not. After gpupdate /force and a fresh logon, gpresult /h for Ann lists the GPO as applied, drive S: appears and the log file is written. For Raj the GPO does not apply and no drive appears, which proves the filter works before any real Sales user is touched.
The gpresult summary for the user scope has this shape (abridged, illustrative; run gpresult /r /scope user as the pilot user). For Ann:
USER SETTINGS
Applied Group Policy Objects
-----------------------------
Sales - User Environment
For Raj the same GPO moves to the other list, with the reason:
The following GPOs were not applied because they were filtered out
-------------------------------------------------------------------
Sales - User Environment
Filtering: Denied (Security)
Read it as: the GPO name under "Applied Group Policy Objects" is the "must appear as applied" check, and a GPO listed under "filtered out" with a Security reason means the security filtering did its job.
Pitfalls
- A preference that a policy also sets loses to the policy. For example, when a registry preference sets the screen saver timeout to 600 seconds and the policy in this GPO sets 900, the user ends up with 900.
- The preference option Apply once and do not reapply (the item is applied the first time only) silently stops the drive from being repaired: a drive the user later disconnects or deletes is never put back.
- A script that needs the share before the drive exists should map by UNC path, not by letter.
- If a change to Location or Reconnect does not reach clients that already have the drive, switch the action to Replace, which deletes and recreates the item.
A web application running as a service account must query a SQL backend as the end user. How do you make that work without granting more trust than necessary, and what changes if the two services sit in different domains?
Sample Answer
Direct answer
Make the web application a delegating service using constrained delegation (Kerberos lets the service obtain tickets to one named back-end service for the signed-in user), preferably the resource-based form, and never unconstrained delegation. First ask whether the SQL queries need the end user's identity at all. If they do, the web application's account, its Service Principal Names (SPNs, the names Kerberos uses to find a service's account) and the SQL account's delegation settings must all be right. If the two services are in different domains, classic constrained delegation cannot work and resource-based delegation can.
Why a plain service account is not enough
The user signs in to the web application (hop 1), and the web application then calls SQL (hop 2). The web application receives proof of the user's identity for itself only. NTLM cannot carry the identity across the second hop, so Kerberos delegation is required. That is the double-hop problem.
A user-by-user trace. Alice signs in to the web application with Kerberos (hop 1), so the application holds a ticket proving Alice to the application, and nothing usable at SQL. For hop 2 the application, running as CORP\webapp$, asks the domain controller's Kerberos service for a ticket to MSSQLSvc/sqlhost in Alice's name. The domain controller checks one list: in classic delegation, whether the SQL SPN is in the front end's allowed-to-delegate-to list; in resource-based delegation, whether the front end is named on the SQL account. If yes, SQL sees CORP\alice. If no, the request is refused and SQL sees either a failed Kerberos login or an NTLM fallback with the application's own identity.
The three delegation types
| Type | Who configures it | What it allows | Risk |
|---|---|---|---|
| Unconstrained | Set on the front-end account | The service can impersonate the user to any service | Any compromise of the front end exposes every service the user can reach |
| Constrained (classic) | Domain admin, on the front-end account | Impersonation only to the listed back-end services, within one domain | Limited to the listed services, but the front-end admin decides |
| Resource-based constrained (RBCD) | The owner of the back-end account, on the back-end object | Impersonation only by the front-end accounts listed there; can cross domains | Control sits with the resource owner, so a risky front end is easy to refuse |
Microsoft's description of the 2012 change: it moves the decision about trusting a delegating front end from the front end's domain administrator to the resource owner. Concretely, classic delegation is edited on the front end's object, and changing it needs the "Enable computer and user accounts to be trusted for delegation" right, which Domain Admins hold by default. Resource-based delegation is edited on the SQL account's object, so the SQL owner alone decides which front ends may reach it, without involving the front end's administrators.
Same domain: steps
- Run the web application's pool or service as a group managed service account (gMSA, a domain account whose password the directory rotates); IIS application pools and Windows services can use one.
- Register the SQL SPN on the account that runs SQL Server, for example
setspn -S MSSQLSvc/sqlhost.corp.example.com:1433 CORP\sqlsvc. If the SPN is missing or wrong, Kerberos is not used at all, so delegation cannot happen. - Configure delegation to exactly that SPN (classic), or set the allowed front end on the SQL account (RBCD). For classic, edit the front end's object. In Active Directory Users and Computers this is the Delegation tab with "Trust this user for delegation to specified services only"; in PowerShell:
# Classic: set on the FRONT END account (here the gMSA 'webapp'); lists the one SPN it may delegate to.
Set-ADServiceAccount -Identity 'webapp' -Add @{ 'msDS-AllowedToDelegateTo' = 'MSSQLSvc/sqlhost.corp.example.com:1433' }
Get-ADServiceAccount -Identity 'webapp' -Properties 'msDS-AllowedToDelegateTo' | Select-Object Name, 'msDS-AllowedToDelegateTo'
Illustrative read-back (not a captured run): webapp with {MSSQLSvc/sqlhost.corp.example.com:1433} in the second column means the front end may delegate to that service and nothing else. For RBCD in one domain, use the same Set-ADUser ... -PrincipalsAllowedToDelegateToAccount form shown in the cross-domain section, with both accounts in the same domain.
4. If the web application authenticates users by a method other than Kerberos (forms login, certificates), it needs protocol transition. Example: Bob types a username and password into a web form, so the application never receives a Kerberos ticket for Bob. It must ask the domain controller to produce a ticket for Bob without his password, and the domain controller only does that for a front end that is allowed to. Classic constrained delegation needs the Trusted-to-Authenticate-for-Delegation setting for that (in Users and Computers: "Use any authentication protocol" instead of "Use Kerberos only"; in PowerShell Set-ADAccountControl -Identity 'webapp$' -TrustedToAuthForDelegation $true). With RBCD the KDC (Key Distribution Center, the domain controller's Kerberos service) always allows it, so the back end can still tell how the user was authenticated: the ticket carries one of two well-known SIDs. S-1-18-1 (authentication authority asserted identity) means a domain controller verified the user directly. S-1-18-2 (service asserted identity) means the front end vouched for the user through protocol transition. A back end can require S-1-18-1 in an access check for sensitive data, so that a user who was only vouched for by a service is refused.
5. Protect the users: members of Protected Users (a built-in group whose members get hardened sign-in rules, including that their credentials cannot be delegated) and accounts marked "Account is sensitive and cannot be delegated" cannot be delegated. That is a feature, and administrators will see failures through this application.
If the services are in different domains
Classic constrained delegation restricts the account to a single domain. Resource-based delegation lets the owner of the SQL account in domain B list the front-end account from domain A:
# Front end: gMSA "webapp" (domain A). Back end: SQL Server service account "sqlsvc" (domain B).
# Delegation is configured on the BACK END object and lists the front end that may impersonate users to it.
$front = Get-ADServiceAccount -Identity 'webapp' -Server 'dc01.a.example.com'
Set-ADUser -Identity 'sqlsvc' -Server 'dc01.b.example.com' -PrincipalsAllowedToDelegateToAccount $front
# Read it back from the back-end object.
Get-ADUser -Identity 'sqlsvc' -Server 'dc01.b.example.com' -Properties PrincipalsAllowedToDelegateToAccount |
Select-Object Name, PrincipalsAllowedToDelegateToAccount
This script was parse-checked with PowerShell 7 and its cmdlets and parameters checked against Microsoft Learn. It was not run, because it needs the ActiveDirectory module and two real domains. It assumes the domains already trust each other.
Verify it works
Run a test through the web application, from a client other than the SQL server, and read the connection that SQL sees:
SELECT c.auth_scheme, s.login_name
FROM sys.dm_exec_connections AS c
JOIN sys.dm_exec_sessions AS s ON s.session_id = c.session_id
WHERE c.session_id = @@SPID;
You expect KERBEROS and the end user's name. Illustrative result for a test as Alice (not a captured run):
auth_scheme login_name
----------- ----------
KERBEROS CORP\alice
If the first column says NTLM, or the login name is the application's account, the Kerberos second hop did not happen. SQL Server's own documentation notes that local connections use NTLM, so test remotely.
Trade-offs and pitfalls
- If the queries do not need per-user identity, have the application use its own identity and enforce per-user rules in code (the trusted subsystem model: the database trusts the application's identity, and the application decides who may do what). That removes delegation entirely.
- Delegation lists grow stale: audit them, and remove entries when an application is retired.
- Clocks, DNS and a correct SPN are the usual failures, not the delegation setting.
Unlock Full Question Bank
Get access to all 33 Active Directory Architecture and Management interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.