index
int64 0
4.08k
| text
stringlengths 34
4.9k
⌀ | url
stringclasses 38
values |
|---|---|---|
64
|
Detecting and Mitigating Microsoft Active Directory Compromises 59
4104 Microsoft Entra
Connect
PowerShell script block logging.
Computer objects configured for unconstrained delegation events
The events in Table 22 should be centrally logged and analysed in a timely manner to identify Active Directory
compromises involving computer objects configured for unconstrained delegation.
Table 22. Events that detect compromises involving computer objects configured for unconstrained delegation
Event ID Compromise Description
4103 Unconstrained
delegation
PowerShell executes and logs pipeline execution details.
4104 Unconstrained
delegation
PowerShell executes code to capture scripts and commands.
4624 Unconstrained
delegation
An account is successfully logged on.
4688 Unconstrained
delegation
A new process is created.
Computer objects compromised by a Silver Ticket
The events in Table 23 should be centrally logged and analysed in a timely manner to identify Active Directory
compromises involving Silver Tickets.
Table 23. Events that detect Silver Ticket compromises
Event ID Compromise Description
4624 Silver Ticket This event is generated when an account is logged into a computer. It can be
correlated and analysed with event 4627 for signs of a potential Silver Ticket.
4627 Silver Ticket This event is generated alongside event 4624 and provides additional
information regarding the group membership of the account that logged in. This
event can be analysed for discrepancies, such as mismatching SID and group
membership information for the user object that logged on. Note that a Silver
Ticket forges the TGS, which can contain false information, such as a different
SID to the user object logging on and different group memberships. Malicious
actors falsify this information to escalate their privileges on the target computer
object.
|
https://media.defense.gov/2024/Sep/25/2003553985/-1/-1/0/CTR-Detecting-and-Mitigating-AD-Compromises.PDF
|
65
|
Detecting and Mitigating Microsoft Active Directory Compromises 60
Glossary
Acronym Definition
AD CS Active Directory Certificate Services
AD DS Active Directory Domain Services
AD FS Active Directory Federation Services
API application programming interface
ASD Australian Signals Directorate
AS-REP Authentication Server Response
CA Certificate Authority
DKM Distributed Key Manager
DPAPI data protection application programming interface
EKU Extended Key Usage
gMSA group Managed Service Account
GPP Group Policy Preference
GUID Globally Unique Identifier
HSM hardware security module
IT information technology
KDC Key Distribution Centre
KRBTGT Kerberos Ticket Granting Ticket
LAN local area network
LAPS Local Administrator Password Solution
LDAP Lightweight Directory Access Protocol
LM LAN Manager
|
https://media.defense.gov/2024/Sep/25/2003553985/-1/-1/0/CTR-Detecting-and-Mitigating-AD-Compromises.PDF
|
66
|
Detecting and Mitigating Microsoft Active Directory Compromises 61
LSA Local Security Authority
LSASS Local Security Authority Subsystem Service
MFA multi-factor authentication
NTLM New Technology Local Area Network Manager
PHS Password Hash Synchronisation
PTA Pass-Through Authentication
PtH Pass the Hash
SACL System Access Control List
SAML Security Assertion Markup Language
SAN Subject Alternative Name
SIEM security information and event management
SMB Server Message Block
SOC security operations centre
SPN service principal name
SQL Structured Query Language
SYSVOL system volume
TDO trusted domain object
TGS Ticket Granting Service
TGT Ticket Granting Ticket
|
https://media.defense.gov/2024/Sep/25/2003553985/-1/-1/0/CTR-Detecting-and-Mitigating-AD-Compromises.PDF
|
67
|
Disclaimer
The material in this guide is of a general nature and should not be regarded as legal advice or relied on for assistance
in any particular circumstance or emergency situation. In any important matter, you should seek appropriate
independent professional advice in relation to your own circumstances.
The Commonwealth accepts no responsibility or liability for any damage, loss or expense incurred as a result of the
reliance on information contained in this guide.
Copyright
© Commonwealth of Australia 2024.
With the exception of the Coat of Arms, the Australian Signals Directorate logo and where otherwise stated, all
material presented in this publication is provided under a Creative Commons Attribution 4.0 International licence
(www.creativecommons.org/licenses).
For the avoidance of doubt, this means this licence only applies to material as set out in this document.
The details of the relevant licence conditions are available on the Creative Commons website as is the full legal code
for the CC BY 4.0 licence (www.creativecommons.org/licenses).
Use of the Coat of Arms
The terms under which the Coat of Arms can be used are detailed on the Department of the Prime Minister and
Cabinet website (www.pmc.gov.au/government/commonwealth-coat-arms).
For more information, or to report a cyber security incident, contact us:
cyber.gov.au | 1300 CYBER1 (1300 292 371)
|
https://media.defense.gov/2024/Sep/25/2003553985/-1/-1/0/CTR-Detecting-and-Mitigating-AD-Compromises.PDF
|
0
| null |
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
1
| null |
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
2
|
Brian Svidergol and Robbie Allen
FOURTH EDITION
Active Directory Cookbook
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
3
|
Active Directory Cookbook, Fourth Edition
by Brian Svidergol and Robbie Allen
Copyright © 2013 Brian Svidergol and Robbie Allen. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or corporate@oreilly.com.
Editors: Maria Gulick and Rachel Roumeliotis
Production Editor: Melanie Yarbrough
Copyeditor: Audrey Doyle
Proofreader: BIM Publishing Services
Indexer: Ellen Troutman-Zaig
Cover Designer: Randy Comer
Interior Designer: David Futato
Illustrator: Rebecca Demarest
June 2013: Fourth Edition
Revision History for the Fourth Edition:
2013-05-24: First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449361426 for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. Active Directory Cookbook, Fourth Edition, the image of a bluefin tuna, and related trade dress
are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐
mark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-36142-6
[LSI]
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
4
|
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
1. Getting Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1. Approach to the Book 1
1.2. Where to Find the Tools 3
1.3. Getting Familiar with LDIF 4
1.4. Replaceable Text 6
1.5. Where to Find More Information 6
2. Forests, Domains, and Trusts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1. Creating a Forest 15
2.2. Removing a Forest 18
2.3. Creating a Domain 19
2.4. Removing a Domain 20
2.5. Removing an Orphaned Domain 22
2.6. Finding the Domains in a Forest 23
2.7. Finding the NetBIOS Name of a Domain 24
2.8. Renaming a Domain 25
2.9. Raising the Domain Functional Level to Windows Server 2012 27
2.10. Raising the Functional Level of a Windows Server 2008 or 2008 R2
Forest 28
2.11. Using AdPrep to Prepare a Domain or Forest for Windows Server 2012 30
2.12. Determining Whether AdPrep Has Completed 31
2.13. Checking Whether a Windows Domain Controller Can Be Upgraded to
Windows Server 2003 or 2008 34
2.14. Creating an External Trust 35
2.15. Creating a Transitive Trust Between Two AD Forests 37
2.16. Creating a Shortcut Trust Between Two AD Domains 38
2.17. Creating a Trust to a Kerberos Realm 40
iii
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
5
|
2.18. Viewing the Trusts for a Domain 41
2.19. Verifying a Trust 43
2.20. Resetting a Trust 45
2.21. Removing a Trust 45
2.22. Enabling SID Filtering for a Trust 47
2.23. Enabling Quarantine for a Trust 48
2.24. Managing Selective Authentication for a Trust 49
2.25. Finding Duplicate SIDs in a Domain 51
2.26. Adding Additional Fields to Active Directory Users and Computers 52
3. Domain Controllers, Global Catalogs, and FSMOs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.1. Promoting a Server to a Domain Controller 58
3.2. Promoting a Server to a Read-Only Domain Controller 59
3.3. Performing a Two-Stage RODC Installation 61
3.4. Modifying the Password Replication Policy 62
3.5. Promoting a Server to a Windows Server 2012 Domain Controller from
Media 64
3.6. Demoting a Domain Controller 66
3.7. Automating the Promotion or Demotion of a Domain Controller 67
3.8. Troubleshooting Domain Controller Promotion or Demotion Problems 68
3.9. Verifying the Promotion of a Domain Controller 70
3.10. Removing an Unsuccessfully Demoted Domain Controller 71
3.11. Renaming a Domain Controller 73
3.12. Finding the Domain Controllers for a Domain 74
3.13. Finding the Closest Domain Controller 75
3.14. Finding a Domain Controller’s Site 76
3.15. Moving a Domain Controller to a Different Site 77
3.16. Finding the Services a Domain Controller Is Advertising 79
3.17. Restoring a Deleted Domain Controller in Windows Server 2012 80
3.18. Resetting the TCP/IP Stack on a Domain Controller 82
3.19. Configuring a Domain Controller to Use an External Time Source 83
3.20. Finding the Number of Logon Attempts Made Against a Domain
Controller 85
3.21. Enabling the /3GB Switch to Increase the LSASS Cache 86
3.22. Enabling and Disabling the Global Catalog 86
3.23. Determining Whether Global Catalog Promotion Is Complete 89
3.24. Finding the Global Catalog Servers in a Forest 90
3.25. Finding the Domain Controllers or Global Catalog Servers in a Site 91
3.26. Finding Domain Controllers and Global Catalogs via DNS 92
3.27. Changing the Preference for a Domain Controller 93
3.28. Disabling the Global Catalog Requirement for User Logon 95
3.29. Finding the FSMO Role Holders 95
iv | Table of Contents
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
6
|
3.30. Transferring a FSMO Role 97
3.31. Seizing a FSMO Role 99
3.32. Finding the PDC Emulator FSMO Role Owner via DNS 100
4. Searching and Manipulating Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
4.1. Viewing the RootDSE 104
4.2. Viewing the Attributes of an Object 106
4.3. Counting Objects in Active Directory 110
4.4. Using LDAP Controls 112
4.5. Using a Fast or Concurrent Bind 114
4.6. Connecting to an Object GUID 116
4.7. Connecting to a Well-Known GUID 117
4.8. Searching for Objects in a Domain 120
4.9. Searching the Global Catalog 122
4.10. Searching for a Large Number of Objects 124
4.11. Searching with an Attribute-Scoped Query 126
4.12. Searching with a Bitwise Filter 128
4.13. Creating an Object 131
4.14. Modifying an Object 134
4.15. Modifying a Bit-Flag Attribute 136
4.16. Dynamically Linking an Auxiliary Class 139
4.17. Creating a Dynamic Object 140
4.18. Refreshing a Dynamic Object 142
4.19. Modifying the Default TTL Settings for Dynamic Objects 144
4.20. Moving an Object to a Different OU or Container 145
4.21. Moving an Object to a Different Domain 147
4.22. Referencing an External Domain 149
4.23. Renaming an Object 150
4.24. Deleting an Object 153
4.25. Deleting a Container That Has Child Objects 155
4.26. Viewing the Created and Last-Modified Timestamp of an Object 156
4.27. Modifying the Default LDAP Query Policy 157
4.28. Exporting Objects to an LDIF File 159
4.29. Importing Objects Using an LDIF File 160
4.30. Exporting Objects to a CSV File 161
4.31. Importing Objects Using PowerShell and a CSV File 162
5. Organizational Units. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
5.1. Creating an OU 166
5.2. Enumerating the OUs in a Domain 168
5.3. Finding an OU 169
5.4. Enumerating the Objects in an OU 170
Table of Contents | v
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
7
|
5.5. Deleting the Objects in an OU 172
5.6. Deleting an OU 173
5.7. Moving the Objects in an OU to a Different OU 175
5.8. Moving an OU 177
5.9. Renaming an OU 178
5.10. Modifying an OU 179
5.11. Determining Approximately How Many Child Objects an OU Has 181
5.12. Delegating Control of an OU 182
5.13. Assigning or Removing a Manager for an OU 183
5.14. Linking a GPO to an OU 185
5.15. Protecting an OU Against Accidental Deletion 186
6. Users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
6.1. Modifying the Default Display Name Used When Creating Users in
ADUC or ADAC 191
6.2. Creating a User 192
6.3. Creating a Large Number of Users 194
6.4. Creating an inetOrgPerson User 196
6.5. Converting a user Object to an inetOrgPerson Object (or Vice Versa) 198
6.6. Modifying an Attribute for Several Users at Once 200
6.7. Deleting a User 201
6.8. Setting a User’s Profile Attributes 202
6.9. Moving a User 203
6.10. Redirecting Users to an Alternative OU 205
6.11. Renaming a User 206
6.12. Copying a User 208
6.13. Finding Locked-Out Users 209
6.14. Unlocking a User 210
6.15. Troubleshooting Account Lockout Problems 211
6.16. Viewing the Domain-Wide Account Lockout and Password Policies 213
6.17. Applying a Fine-Grained Password Policy to a User Object 216
6.18. Viewing the Fine-Grained Password Policy That Is in Effect for a User
Account 217
6.19. Enabling and Disabling a User 218
6.20. Finding Disabled Users 219
6.21. Viewing a User’s Group Membership 221
6.22. Removing All Group Memberships from a User 222
6.23. Changing a User’s Primary Group 223
6.24. Copying a User’s Group Membership to Another User 225
6.25. Setting a User’s Password 226
6.26. Preventing a User from Changing a Password 228
6.27. Requiring a User to Change a Password at Next Logon 229
vi | Table of Contents
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
8
|
6.28. Preventing a User’s Password from Expiring 230
6.29. Finding Users Whose Passwords Are About to Expire 231
6.30. Viewing the RODCs That Have Cached a User’s Password 232
6.31. Setting a User’s Account Options (userAccountControl) 233
6.32. Setting a User’s Account to Expire 236
6.33. Determining a User’s Last Logon Time 237
6.34. Finding Users Who Have Not Logged On Recently 238
6.35. Viewing and Modifying a User’s Permitted Logon Hours 240
6.36. Viewing a User’s Managed Objects 242
6.37. Creating a UPN Suffix for a Forest 243
6.38. Restoring a Deleted User 244
6.39. Protecting a User Against Accidental Deletion 245
7. Groups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
7.1. Creating a Group 249
7.2. Viewing the Permissions of a Group 251
7.3. Viewing the Direct Members of a Group 252
7.4. Viewing the Nested Members of a Group 253
7.5. Adding and Removing Members of a Group 254
7.6. Moving a Group Within a Domain 256
7.7. Moving a Group to Another Domain 257
7.8. Changing the Scope or Type of a Group 259
7.9. Modifying Group Attributes 260
7.10. Delegating Control for Managing Membership of a Group 263
7.11. Resolving a Primary Group ID 264
7.12. Enabling Universal Group Membership Caching 266
7.13. Restoring a Deleted Group 268
7.14. Protecting a Group Against Accidental Deletion 269
7.15. Applying a Fine-Grained Password Policy to a Group Object 270
8. Computer Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
8.1. Creating a Computer 274
8.2. Creating a Computer for a Specific User or Group 276
8.3. Deleting a Computer 278
8.4. Joining a Computer to a Domain 278
8.5. Moving a Computer Within the Same Domain 280
8.6. Moving a Computer to a New Domain 281
8.7. Renaming a Computer 283
8.8. Adding or Removing a Computer Account from a Group 285
8.9. Testing the Secure Channel for a Computer 286
8.10. Resetting a Computer Account 287
8.11. Finding Inactive or Unused Computers 289
Table of Contents | vii
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
9
|
8.12. Changing the Maximum Number of Computers a User Can Join to the
Domain 290
8.13. Modifying the Attributes of a computer Object 292
8.14. Finding Computers with a Particular OS 294
8.15. Binding to the Default Container for Computers 296
8.16. Changing the Default Container for Computers 298
8.17. Listing All the Computer Accounts in a Domain 300
8.18. Identifying a Computer Role 301
8.19. Protecting a Computer Against Accidental Deletion 302
8.20. Viewing the RODCs That Have Cached a Computer’s Password 303
9. Group Policy Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
9.1. Finding the GPOs in a Domain 307
9.2. Creating a GPO 309
9.3. Copying a GPO 310
9.4. Deleting a GPO 311
9.5. Viewing the Settings of a GPO 312
9.6. Modifying the Settings of a GPO 313
9.7. Importing Settings into a GPO 314
9.8. Creating a Migration Table 316
9.9. Creating Custom Group Policy Settings 317
9.10. Assigning Logon/Logoff and Startup/Shutdown Scripts in a GPO 320
9.11. Installing Applications with a GPO 321
9.12. Disabling the User or Computer Settings in a GPO 322
9.13. Listing the Links for a GPO 323
9.14. Creating a GPO Link to an OU 324
9.15. Blocking Inheritance of GPOs on an OU 325
9.16. Enforcing the Settings of a GPO Link 326
9.17. Applying a Security Filter to a GPO 327
9.18. Delegating Administration of GPOs 329
9.19. Importing a Security Template 331
9.20. Creating a WMI Filter 332
9.21. Applying a WMI Filter to a GPO 333
9.22. Configuring Loopback Processing for a GPO 334
9.23. Backing Up a GPO 335
9.24. Restoring a GPO 337
9.25. Simulating the RSoP 338
9.26. Viewing the RSoP 339
9.27. Refreshing GPO Settings on a Computer 340
9.28. Restoring a Default GPO 341
9.29. Creating a Fine-Grained Password Policy 342
9.30. Editing a Fine-Grained Password Policy 343
viii | Table of Contents
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
10
|
9.31. Viewing the Effective PSO for a User 345
10. Schema. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
10.1. Registering the Active Directory Schema MMC Snap-in 349
10.2. Generating an OID to Use for a New Class or Attribute 350
10.3. Extending the Schema 351
10.4. Preparing the Schema for an Active Directory Upgrade 352
10.5. Documenting Schema Extensions 353
10.6. Adding a New Attribute 354
10.7. Viewing an Attribute 358
10.8. Adding a New Class 360
10.9. Viewing a Class 362
10.10. Indexing an Attribute 363
10.11. Modifying the Attributes That Are Copied When Duplicating a User 365
10.12. Modifying the Attributes Included with ANR 367
10.13. Modifying the Set of Attributes Stored on a Global Catalog 369
10.14. Finding Nonreplicated and Constructed Attributes 371
10.15. Finding the Linked Attributes 373
10.16. Finding the Structural, Auxiliary, Abstract, and 88 Classes 375
10.17. Finding the Mandatory and Optional Attributes of a Class 377
10.18. Modifying the Default Security of a Class 378
10.19. Managing the Confidentiality Bit 379
10.20. Adding an Attribute to the Read-Only Filtered Attribute Set (RO-FAS) 381
10.21. Deactivating Classes and Attributes 382
10.22. Redefining Classes and Attributes 383
10.23. Reloading the Schema Cache 384
10.24. Managing the Schema Master FSMO 386
11. Site Topology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
11.1. Creating a Site 393
11.2. Listing Sites in a Domain 395
11.3. Renaming a Site 396
11.4. Deleting a Site 397
11.5. Delegating Control of a Site 398
11.6. Configuring Universal Group Caching for a Site 399
11.7. Creating a Subnet 401
11.8. Listing the Subnets 402
11.9. Finding Missing Subnets 403
11.10. Deleting a Subnet 405
11.11. Changing a Subnet’s Site Assignment 406
11.12. Creating a Site Link 407
11.13. Finding the Site Links for a Site 409
Table of Contents | ix
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
11
|
11.14. Modifying the Sites That Are Part of a Site Link 410
11.15. Modifying the Cost for a Site Link 411
11.16. Enabling Change Notification for a Site Link 412
11.17. Modifying Replication Schedules 413
11.18. Disabling Site Link Transitivity or Site Link Schedules 415
11.19. Creating a Site Link Bridge 416
11.20. Finding the Bridgehead Servers for a Site 418
11.21. Setting a Preferred Bridgehead Server for a Site 419
11.22. Listing the Servers 421
11.23. Moving a Domain Controller to a Different Site 422
11.24. Configuring a Domain Controller to Cover Multiple Sites 423
11.25. Viewing the Site Coverage for a Domain Controller 424
11.26. Disabling Automatic Site Coverage for a Domain Controller 425
11.27. Finding the Site for a Client 426
11.28. Forcing a Host into a Particular Site 427
11.29. Creating a connection Object 428
11.30. Listing the connection Objects for a Server 429
11.31. Finding the ISTG for a Site 429
11.32. Transferring the ISTG to Another Server 431
11.33. Triggering the KCC 432
11.34. Determining Whether the KCC Is Completing Successfully 433
11.35. Disabling the KCC for a Site 434
11.36. Changing the Interval at Which the KCC Runs 436
12. Replication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
12.1. Determining Whether Two Domain Controllers Are in Sync 439
12.2. Viewing the Replication Status of Several Domain Controllers 440
12.3. Viewing Unreplicated Changes Between Two Domain Controllers 441
12.4. Forcing Replication from One Domain Controller to Another 442
12.5. Enabling and Disabling Replication 444
12.6. Changing the Intra-Site Replication Notification Interval 445
12.7. Changing the Inter-Site Replication Interval 446
12.8. Disabling Inter-Site Compression of Replication Traffic 448
12.9. Checking for Potential Replication Problems 449
12.10. Enabling Enhanced Logging of Replication Events 450
12.11. Enabling Strict or Loose Replication Consistency 450
12.12. Finding conflict Objects 452
12.13. Finding Orphaned Objects 453
12.14. Listing the Replication Partners for a DC 455
12.15. Viewing Object Metadata 456
13. DNS and DHCP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
x | Table of Contents
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
12
|
13.1. Creating a Forward Lookup Zone 463
13.2. Creating a Reverse Lookup Zone 464
13.3. Viewing a Server’s Zones 466
13.4. Converting a Zone to an AD Integrated Zone 468
13.5. Moving AD Integrated Zones into an Application Partition 469
13.6. Configuring Zone Transfers 470
13.7. Configuring Forwarding 471
13.8. Configuring Conditional Forwarding 473
13.9. Delegating Control of an Active Directory Integrated Zone 474
13.10. Creating and Deleting Resource Records 475
13.11. Querying Resource Records 478
13.12. Modifying the DNS Server Configuration 479
13.13. Scavenging Old Resource Records 480
13.14. Clearing the DNS Cache 482
13.15. Verifying That a Domain Controller Can Register Its Resource Records 484
13.16. Enabling DNS Server Debug Logging 485
13.17. Registering a Domain Controller’s Resource Records 488
13.18. Deregistering a Domain Controller’s Resource Records 488
13.19. Preventing a Domain Controller from Dynamically Registering All
Resource Records 489
13.20. Preventing a Domain Controller from Dynamically Registering Certain
Resource Records 490
13.21. Allowing Computers to Use a Domain Suffix That Is Different from
Their AD Domain 493
13.22. Authorizing a DHCP Server 495
13.23. Restricting DHCP Administrators 497
14. Security and Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
14.1. Enabling SSL/TLS 502
14.2. Securing LDAP Traffic with SSL, TLS, or Signing 503
14.3. Disabling LDAP Signing 504
14.4. Enabling Anonymous LDAP Access 505
14.5. Using the Delegation of Control Wizard 507
14.6. Customizing the Delegation of Control Wizard 509
14.7. Revoking Delegated Permissions 512
14.8. Viewing the ACL for an Object 513
14.9. Customizing the ACL Editor 514
14.10. Viewing the Effective Permissions on an Object 515
14.11. Configuring Permission Inheritance 516
14.12. Changing the ACL of an Object 518
14.13. Changing the Default ACL for an Object Class in the Schema 519
14.14. Comparing the ACL of an Object to the Default Defined in the Schema 520
Table of Contents | xi
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
13
|
14.15. Resetting an Object’s ACL to the Default Defined in the Schema 521
14.16. Enabling Strong Domain Authentication 521
14.17. Enabling List Object Access Mode 523
14.18. Modifying the ACL on Administrator Accounts 525
14.19. Viewing and Purging Your Kerberos Tickets 526
14.20. Forcing Kerberos to Use TCP 527
14.21. Modifying Kerberos Settings 529
14.22. Viewing Access Tokens 530
14.23. Creating a Claim Type 531
14.24. Creating a Resource Property 532
14.25. Configuring a Central Access Rule 533
14.26. Creating a Central Access Policy 534
14.27. Applying a Central Access Policy 535
14.28. Enabling Domain Controller Support for Claims and Compound
Authentication 535
14.29. Enabling Claims for Devices in a Domain 536
15. Logging, Monitoring, and Quotas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
15.1. Enabling Diagnostics Logging 540
15.2. Enabling NetLogon Logging 542
15.3. Enabling GPO Client Logging 543
15.4. Enabling Kerberos Logging 545
15.5. Viewing DNS Server Performance Statistics 546
15.6. Monitoring the Windows Time Service 548
15.7. Enabling Inefficient and Expensive LDAP Query Logging 549
15.8. Using the STATS Control to View LDAP Query Statistics 551
15.9. Monitoring the Performance of Active Directory 554
15.10. Using Perfmon Trace Logs to Monitor Active Directory 557
15.11. Creating an Administrative Alert 559
15.12. Emailing an Administrator on a Performance Alert 560
15.13. Enabling Auditing of Directory Access 561
15.14. Enabling Auditing of Registry Keys 564
15.15. Creating a Quota 565
15.16. Finding the Quotas Assigned to a Security Principal 567
15.17. Changing How Tombstone Objects Count Against Quota Usage 568
15.18. Setting the Default Quota for All Security Principals in a Partition 570
15.19. Finding the Quota Usage for a Security Principal 571
16. Backup, Recovery, DIT Maintenance, and Deleted Objects. . . . . . . . . . . . . . . . . . . . . . . 575
16.1. Backing Up the Active Directory Database 578
16.2. Creating an Active Directory Snapshot 579
16.3. Mounting an Active Directory Snapshot 580
xii | Table of Contents
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
14
|
16.4. Accessing Active Directory Snapshot Data 581
16.5. Restarting a Domain Controller in Directory Services Repair Mode 582
16.6. Resetting the Directory Services Repair Mode Administrator Password 584
16.7. Performing a Nonauthoritative Restore 585
16.8. Performing an Authoritative Restore of an Object or Subtree 586
16.9. Performing a Complete Authoritative Restore 588
16.10. Checking the DIT File’s Integrity 589
16.11. Moving the DIT Files 590
16.12. Repairing or Recovering the DIT 591
16.13. Performing an Online Defrag Manually 592
16.14. Performing a Database Recovery 593
16.15. Creating a Reserve File 595
16.16. Determining How Much Whitespace Is in the DIT 596
16.17. Performing an Offline Defrag to Reclaim Space 597
16.18. Changing the Garbage Collection Interval 598
16.19. Logging the Number of Expired Tombstone Objects 600
16.20. Determining the Size of the Active Directory Database 601
16.21. Searching for Deleted Objects 602
16.22. Undeleting a Single Object 603
16.23. Undeleting a Container Object 604
16.24. Modifying the Tombstone Lifetime for a Domain 605
17. Application Partitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
17.1. Creating and Deleting an Application Partition 608
17.2. Finding the Application Partitions in a Forest 609
17.3. Adding or Removing a Replica Server for an Application Partition 611
17.4. Finding the Replica Servers for an Application Partition 613
17.5. Finding the Application Partitions Hosted by a Server 615
17.6. Verifying Application Partitions Are Instantiated Correctly on a Server 616
17.7. Setting the Replication Notification Delay for an Application Partition 618
17.8. Setting the Reference Domain for an Application Partition 620
17.9. Delegating Control of Managing an Application Partition 621
18. Active Directory Lightweight Directory Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
18.1. Installing AD LDS 626
18.2. Creating a New AD LDS Instance 627
18.3. Creating a New Replica of an AD LDS Configuration Set 629
18.4. Stopping and Starting an AD LDS Instance 631
18.5. Changing the Ports Used by an AD LDS Instance 633
18.6. Listing the AD LDS Instances Installed on a Computer 633
18.7. Extending the AD LDS Schema 634
18.8. Managing AD LDS Application Partitions 636
Table of Contents | xiii
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
15
|
18.9. Managing AD LDS Organizational Units 637
18.10. Managing AD LDS Users 639
18.11. Changing the Password for an AD LDS User 640
18.12. Enabling and Disabling an AD LDS User 641
18.13. Creating AD LDS Groups 643
18.14. Managing AD LDS Group Memberships 644
18.15. Viewing and Modifying AD LDS Object Attributes 645
18.16. Importing Data into an AD LDS Instance 647
18.17. Configuring Intra-Site Replication 648
18.18. Forcing AD LDS Replication 649
18.19. Managing AD LDS Replication Authentication 650
18.20. Managing AD LDS Permissions 652
18.21. Enabling Auditing of AD LDS Access 654
19. Active Directory Federation Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
19.1. Installing AD FS Prerequisites 658
19.2. Installing the AD FS Federation Service 660
19.3. Configuring an LDAP Attribute Store 661
19.4. Configuring a Microsoft SQL Server Attribute Store 662
19.5. Creating Claim Descriptions 663
19.6. Creating a Relying Party Trust 664
19.7. Configuring a Claims Provider Trust 665
19.8. Configuring an Alternate UPN Suffix 666
19.9. Configuring AD FS 2.x and AD FS 1.x Interoperability 668
19.10. Configuring Logging for AD FS 671
20. Microsoft Exchange Server 2013. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
20.1. Exchange Server and Active Directory 673
20.2. Exchange Server 2013 Architecture 674
20.3. Finding Exchange Server Cmdlets 675
20.4. Preparing Active Directory for Exchange 676
20.5. Installing the First Exchange Server 2013 Server in an Organization 679
20.6. Creating Unattended Installation Files for Exchange Server 682
20.7. Installing Exchange Management Tools 683
20.8. Stopping and Starting Exchange Server 684
20.9. Mail-Enabling a User 687
20.10. Mail-Disabling a User 688
20.11. Mailbox-Enabling a User 689
20.12. Deleting a User’s Mailbox 691
20.13. Moving a Mailbox 693
20.14. Viewing Mailbox Sizes and Message Counts 695
20.15. Configuring Mailbox Limits 698
xiv | Table of Contents
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
16
|
20.16. Creating an Address List 700
20.17. Creating a Database Availability Group 701
20.18. Creating a Mailbox Database 703
20.19. Enabling or Disabling Anti-Malware Scanning 704
20.20. Enabling Message Tracking 705
21. Microsoft Forefront Identity Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
21.1. Creating a SQL Server Management Agent 722
21.2. Creating an Active Directory Management Agent 724
21.3. Setting Up a Metaverse Object Deletion Rule 726
21.4. Setting Up a Simple Import Attribute Flow 727
21.5. Setting Up a Simple Export Attribute Flow to Active Directory 729
21.6. Defining an Advanced Import Attribute Flow 731
21.7. Implementing an Advanced Attribute Flow Rules Extension 733
21.8. Setting Up Advanced Export Attribute Flow in Active Directory 736
21.9. Configuring a Run Profile to Do an Initial Load of Data from a SQL
Server Management Agent 737
21.10. Loading Initial SQL Server Database Data into FIM 2010 R2 Using a
Run Profile 739
21.11. Configuring a Run Profile to Load the Container Structure from Active
Directory 740
21.12. Loading the Initial Active Directory Container Structure into FIM 2010
R2 Using a Run Profile 742
21.13. Setting Up a SQL Server Management Agent to Project Objects to the
Metaverse 743
21.14. Writing a Rules Extension to Provision User Objects 744
21.15. Creating a Run Profile for Provisioning 747
21.16. Executing the Provisioning Rule 749
21.17. Creating a Run Profile to Export Objects from the AD MA to Active
Directory 750
21.18. Exporting Objects to Active Directory Using an Export Run Profile 752
21.19. Creating a Run Profile Script 753
21.20. Creating a Controlling Script 755
21.21. Enabling Directory Synchronization from Active Directory to the HR
Database 761
21.22. Configuring a Run Profile to Load the telephoneNumber from Active
Directory 762
21.23. Loading telephoneNumber Changes from AD into FIM Using a Delta
Import/Delta Sync Run Profile 765
21.24. Exporting telephoneNumber Data to a SQL Server Database 767
21.25. Using a SQL Server MA Export Run Profile to Export the
telephoneNumber to a SQL Server Database 768
Table of Contents | xv
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
17
|
21.26. Searching Data in the Connector Space 769
21.27. Searching Data in the Metaverse 771
21.28. Deleting Data in the Connector Space and Metaverse 772
21.29. Extending Object Types to Include a New Attribute 773
21.30. Previewing Changes to the FIM Configuration 774
21.31. Committing Changes to Individual Identities Using the Commit
Preview Feature 777
21.32. Passing Data Between Rules Extensions Using Transaction Properties 778
21.33. Using a Single Rules Extension to Affect Multiple Attribute Flows 779
21.34. Flowing a Null Value to a Data Source 780
21.35. Importing and Decoding the accountExpires Attribute 782
21.36. Exporting and Encoding the accountExpires Attribute 784
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
xvi | Table of Contents
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
18
|
Preface
In 1998, when Robbie first became involved with the Microsoft Windows 2000 Joint
Development Program (JDP), very little data was available on Active Directory (AD).
In the following months, and even after the initial release of Windows 2000, there were
very few books or white papers to help early adopters of Active Directory get started.
And some of the information that had been published was often inaccurate or mislead‐
ing. Many early adopters had to learn by trial and error. As time passed, a greater number
of informative books were published, which helped fill the information gap.
By the end of the second year of its release, there was an explosion of information on
Active Directory. Not only were there more than 50 books published, but Microsoft also
cleaned up its documentation on MSDN and its AD website. Now those sites have
numerous white papers, many of which could serve as mini booklets. Other websites
have popped up as well that contain a great deal of information on Active Directory.
With Windows Server 2008, Windows Server 2008 R2, and Windows Server 2012,
Microsoft has taken its level of documentation a step further. Extensive information on
Active Directory is available directly from any Windows Server 2008 or 2012 computer
in the form of the built-in help information. So, with all this data available on Active
Directory in the form of published books, white papers, websites, and even from within
the operating system, why would you want to purchase this book?
In the summer of 2002, Robbie was thumbing through Tom Christiansen and Nathan
Torkington’s Perl Cookbook (O’Reilly), looking for help with an automation script that
he was writing for Active Directory. It just so happened that there was a recipe that
addressed the specific task he was trying to perform. In Cookbook parlance, a recipe
provides instructions on how to solve a particular problem. We thought that since Active
Directory is such a task-oriented environment, the Cookbook approach might be a very
good format. After a little research, Robbie found there were books (often several) on
nearly every facet of Active Directory, including introductory books, design guides,
books that focused on migration, programming books, and reference books. The one
type of book that he didn’t see was a task-oriented “how to” book, which is exactly what
xvii
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
19
|
the Cookbook format provides. With this was born the first edition of Active Directory
Cookbook, covering Active Directory tasks in Windows 2000 and Windows Server 2003
Active Directory.
In 2005 and again in 2008, Laura E. Hunter revised the already popular Active Directory
Cookbook to include an updated range of automation options, including the use of
command-line tools and scripts that had been created by active members of the Direc‐
tory Services community in the years since AD was first introduced.
Based on our experience, hours of research, and nearly a decade of hanging out on
Active Directory newsgroups and mailing lists, we’ve compiled more than 500 recipes
that should answer the majority of “How do I do X?” questions one could pose about
Active Directory. And just as in the Perl community, where the Perl Cookbook was a
great addition, we believe Active Directory Cookbook, Fourth Edition, will also be a great
addition to any Active Directory library.
Who Should Read This Book?
As with many of the books in the Cookbook series, Active Directory Cookbook, Fourth
Edition, can be useful to anyone who wants to deploy, administer, or automate Active
Directory. This book can serve as a great reference for those who have to work with
Active Directory on a day-to-day basis. For those without much programming back‐
ground, the command-line and PowerShell solutions are straightforward and provide
an easy way to automate repetitive administrative tasks for any administrator.
The companion to this book, Active Directory, Fifth Edition, by Brian Desmond et al.
(O’Reilly), is a great choice for those wanting a thorough description of the core concepts
behind Active Directory, how to design an Active Directory infrastructure, and how to
automate that infrastructure using Active Directory Service Interfaces (ADSI) and
Windows Management Instrumentation (WMI). Active Directory, Fifth Edition, does
not necessarily detail the steps needed to accomplish every possible task within Active
Directory; that is more the intended purpose of this book. These two books, along with
the supplemental information referenced within each, should be sufficient to answer
most questions you have about Active Directory.
What’s in This Book?
This book consists of 21 chapters. Here is a brief overview of each chapter:
Chapter 1, Getting Started
Sets the stage for the book by covering where you can find the tools used in the
book, PowerShell issues to consider, and where to find additional information.
xviii | Preface
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
20
|
Chapter 2, Forests, Domains, and Trusts
Covers how to create and remove forests and domains, update the domain mode
or functional levels, create different types of trusts, and perform other administra‐
tive trust tasks.
Chapter 3, Domain Controllers, Global Catalogs, and FSMOs
Covers promoting and demoting domain controllers, finding domain controllers,
enabling the global catalog, and finding and managing Flexible Single Master Op‐
eration (FSMO) roles.
Chapter 4, Searching and Manipulating Objects
Covers the basics of searching Active Directory: creating, modifying, and deleting
objects; using LDAP controls; and importing and exporting data using LDAP Data
Interchange Format (LDIF) and comma-separated value (CSV) files.
Chapter 5, Organizational Units
Covers creating, moving, and deleting organizational units (OUs), and managing
the objects contained within them.
Chapter 6, Users
Covers all aspects of managing user objects, including creating, renaming, and
moving user objects, resetting passwords, unlocking and modifying the profile at‐
tributes, and locating users that have certain criteria (e.g., password is about to
expire).
Chapter 7, Groups
Covers how to create groups, modify group scope and type, and manage
membership.
Chapter 8, Computer Objects
Covers creating computers, joining computers to a domain, resetting computers,
and locating computers that match certain criteria (e.g., have been inactive for a
number of weeks).
Chapter 9, Group Policy Objects
Covers how to create, modify, link, copy, import, back up, restore, and delete GPOs
using the Group Policy Management snap-in and scripting interface.
Chapter 10, Schema
Covers basic schema administration tasks, such as generating object identifiers
(OIDs) and schemaIDGUIDs, how to use LDIF to extend the schema, and how to
locate attributes or classes that match certain criteria (e.g., all attributes that are
indexed).
Chapter 11, Site Topology
Covers how to manage sites, subnets, site links, and connection objects.
Preface | xix
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
21
|
Chapter 12, Replication
Covers how to trigger and disable the Knowledge Consistency Checker (KCC), and
how to query metadata, force replication, and determine which changes have yet
to replicate between domain controllers.
Chapter 13, DNS and DHCP
Covers how to create zones and resource records, modify DNS server configuration,
query DNS, and customize the resource records a domain controller dynamically
registers.
Chapter 14, Security and Authentication
Covers how to delegate control, view and modify permissions, view effective per‐
missions, and manage Kerberos tickets.
Chapter 15, Logging, Monitoring, and Quotas
Covers how to enable auditing, diagnostics, DNS, NetLogon, and Kerberos and
GPO logging; obtain LDAP query statistics; and manage quotas.
Chapter 16, Backup, Recovery, DIT Maintenance, and Deleted Objects
Covers how to back up Active Directory, perform authoritative and nonauthorita‐
tive restores, check DIT file integrity, perform online and offline defrags, and search
for deleted objects.
Chapter 17, Application Partitions
Covers how to create and manage application partitions.
Chapter 18, Active Directory Lightweight Directory Service
Covers application partitions including Active Directory Lightweight Directory
Services (AD LDS).
Chapter 19, Active Directory Federation Services
Covers Active Directory Federation Services (AD FS) that are included with
Windows Server 2012.
Chapter 20, Microsoft Exchange Server 2013
Covers common administrative tasks for Exchange Server 2013.
Chapter 21, Microsoft Forefront Identity Manager
Provides an introduction to Microsoft’s Forefront Identity Manager (FIM), a service
that can be used to synchronize multiple directories, enforce data integrity within
a single or multiple stores, and provide self-service password reset for end users.
xx | Preface
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
22
|
Conventions Used in This Book
The following typographical conventions are used in this book:
Constant width
Indicates classes, attributes, cmdlets, methods, objects, command-line elements,
computer output, and code examples
Constant width italic
Indicates placeholders (for which you substitute an actual name) in examples and
in registry keys
Constant width bold
Indicates user input
Italic
Introduces new terms and example URLs, commands, file extensions, filenames,
directory or folder names, and UNC pathnames
This icon indicates a tip, suggestion, or general note. For example, we’ll
tell you if you need to use a particular version or if an operation requires
certain privileges.
This icon indicates a warning or caution. For example, we’ll tell you if
Active Directory does not behave as you’d expect or if a particular op‐
eration has a negative impact on performance.
Using Code Examples
This book is here to help you get your job done. In general, if this book includes code
examples, you may use the code in this book in your programs and documentation. You
do not need to contact us for permission unless you’re reproducing a significant portion
of the code. For example, writing a program that uses several chunks of code from this
book does not require permission. Selling or distributing a CD-ROM of examples from
O’Reilly books does require permission. Answering a question by citing this book and
quoting example code does not require permission. Incorporating a significant amount
of example code from this book into your product’s documentation does require per‐
mission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: Active Directory Cookbook, Fourth Edition,
by Brian Svidergol and Robbie Allen. Copyright 2013 O’Reilly Media, Inc.,
978-1-449-36142-6.
Preface | xxi
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
23
|
If you feel your use of code examples falls outside fair use or the permission given here,
feel free to contact us at permissions@oreilly.com.
Safari® Books Online
Safari Books Online (www.safaribooksonline.com) is an on-demand
digital library that delivers expert content in both book and video
form from the world’s leading authors in technology and business.
Technology professionals, software developers, web designers, and business and crea‐
tive professionals use Safari Books Online as their primary resource for research, prob‐
lem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organi‐
zations, government agencies, and individuals. Subscribers have access to thousands of
books, training videos, and prepublication manuscripts in one fully searchable database
from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Pro‐
fessional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John
Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT
Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technol‐
ogy, and dozens more. For more information about Safari Books Online, please visit us
online.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://oreil.ly/active_directory_cb_4.
To comment or ask technical questions about this book, send email to bookques
tions@oreilly.com.
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
xxii | Preface
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
24
|
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
First, let me thank the authors of the original editions—Robbie and Laura—as without
you guys, my job of updating the book for the Fourth Edition would not have been
possible! Thankfully, I was able to start with a fantastic and well-regarded book!
Everybody from O’Reilly has been great. Special thanks go to Rachel Roumeliotis and
Maria Gulick for being easy to work with and helping to move this project along. They
were able to recruit some fantastic technical reviewers. Mike Kline (Directory Services
MVP) provided great practical feedback to bring real-world thinking into every chapter.
I really appreciated his way of looking at the solutions from an administrator’s perspec‐
tive because it helped to ensure that the solutions were real-world and that the solutions
involved the tools that the typical administrator uses. While I hadn’t worked with Mike
before, I was familiar with his extensive work in the community. The other reviewer
was Marcin Policht (Directory Services MVP). I’ve worked with Marcin on quite a few
projects in the past and knew that he would be a valuable addition to the team. His
technical depth and his attention to detail are really incredible, and it showed in his
chapter reviews. Thanks, Mike and Marcin—without you guys, the overall quality of
this edition wouldn’t have been possible!
Other people contributed in other ways. To Ken Jones, thanks for the party invite;
without it, this project never would’ve come to fruition! By the way, Ken, I still often
think back to our first meeting. There were eight SMEs in the room; you were running
the show for the first time. The room was loud and everybody was shouting out in‐
structions like backseat drivers. You showed incredible poise in that situation! Charles
Pluta was my number-one resource when I needed anything. Charles, keep doing what
you are doing and you will go far! Thanks to Elias Mereb—Elias gave me extra moti‐
vation a few years ago and that has helped to fuel me ever since. Evan Hanna—if there
was something strange or unknown, he was always the man to go to. Jonathan Hopp
was there for me even when he didn’t want to be! Of course, I also have to thank my
wife, Lindsay, and my son, Jack, for putting up with me working seven days and seven
nights a week juggling multiple projects. We can now get back to our regularly scheduled
programming!
Preface | xxiii
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
25
| null |
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
26
|
CHAPTER 1
Getting Started
1.1. Approach to the Book
If you are familiar with the O’Reilly Cookbook format, which can be seen in other
popular books such as the Perl Cookbook, Java Cookbook, and DNS and BIND Cook‐
book, then the layout of this book will be familiar to you. The book is composed of 21
chapters, each containing 10 to 30 recipes for performing a specific Active Directory
task. Within each recipe are three sections: “Problem,” “Solution,” and “Discussion.” The
“Problem” section briefly describes the task that the recipe focuses on. The “Solution”
section contains step-by-step instructions on how to accomplish the task. The “Dis‐
cussion” section contains detailed information about the problem or solution. A fourth
section, “See Also,” is included in most recipes and contains references to additional
sources of information that can be useful if you still need more information after reading
the discussion. The “See Also” section may reference other recipes, MS Knowledge
Base articles or documentation from the Microsoft Developer Network (MSDN).
At Least Three Ways to Do It!
When we first began developing the content for the book, we struggled with how to
capture the fact that you can do things in multiple ways with Active Directory. You may
be familiar with the famous computer science motto: TIMTOWTDI, or There Is More
Than One Way To Do It. With Active Directory, there are often At Least Three Ways To
Do It! You can perform a task with a graphical user interface (GUI), such as ADSI Edit,
LDP, Active Directory Administrative Center, or the Active Directory Users and Com‐
puters snap-in; you can use a command-line interface (CLI), such as the ds utilities (i.e.,
dsadd, dsmod, dsrm, dsquery, and dsget), nltest, netdom, or ldifde, or freeware tools such
as adfind and admod from joeware; and finally, you can perform the same task using a
scripting language, such as VBScript, Perl, or PowerShell. Since people prefer different
methods, and no single method is necessarily better than another, we decided to write
solutions to the recipes using one of each. This means that instead of just a single solution
1
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
27
|
per recipe, we include up to three solutions using GUI, CLI, and programmatic exam‐
ples; in some cases you’ll find more than one option for a given solution, as in the case
where there is more than one command-line utility to perform a particular task. How‐
ever, in cases where one of the methods cannot be used or would be too difficult to use
to accomplish a given recipe, only the applicable methods are covered.
A special note regarding PowerShell coverage in this text: PowerShell is a commandline and scripting language introduced by Microsoft. PowerShell’s claim to fame is its
use of a predictable Verb-Noun syntax that can be leveraged regardless of the technology
that it is managing: Get-Object, Get-ChildItem, Get-Mailbox, and so on. This pre‐
dictable syntax is driven by the use of cmdlets (pronounced “command-lets”) that can
be created by individuals and software vendors alike. The first Microsoft product to rely
on PowerShell was Exchange 2007, which includes a rich set of cmdlets to perform
Exchange management tasks. In fact, there are certain tasks in Exchange 2007 that can
only be performed using PowerShell! Since Exchange 2007, virtually every major prod‐
uct released by Microsoft includes a PowerShell module for management.
The challenge that Active Directory administrators faced with PowerShell, prior to the
release of Windows Server 2008 R2, was that a set of PowerShell cmdlets had not yet
been produced by Microsoft to support Active Directory administration tasks. However,
that issue was fixed with the introduction of the PowerShell module for Active Directory.
Microsoft initially released 76 cmdlets specific to Active Directory administration.
Then, with the release of Windows Server 2012, additional cmdlets were introduced. In
total, there are now 145 cmdlets for Active Directory administration! PowerShell has
come a long way since the previous version of this book. As such, all of the Quest
PowerShell cmdlets that were used in the previous version have been replaced with
native cmdlets. Most of the VBScript solutions have also been replaced with simpler
PowerShell solutions.
Readers who are looking for more in-depth programming coverage of these topics
should consult The .NET Developer’s Guide to Directory Services Programming refer‐
enced in the Recipe 1.5 section at the end of this chapter.
Windows Server 2008, Windows Server 2008 R2,
and Windows Server 2012
Another challenge with writing this book is that there are now multiple versions of
Active Directory deployed on most corporate networks. The initial version released
with Windows 2000 was followed by Windows Server 2003 and an incremental update
to Windows Server 2003 R2, and then Microsoft released Windows Server 2008 and
Windows Server 2008 R2, which provided a lot of updates and new features. With the
release of Windows Server 2012, administration has changed and new functionality has
been introduced again. We’ve decided to go with the approach of making everything
work under the most recent version of Active Directory first, and earlier versions of
2 | Chapter 1: Getting Started
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
28
|
Windows second. In fact, the majority of the GUI solutions will work unchanged all the
way back to Windows 2000. The PowerShell solutions will work out of the box with
Windows Server 2008 R2 or newer domain controllers. By using the Active Directory
Management Gateway Service, the PowerShell solutions will work with domain con‐
trollers running Windows Server 2003 SP2 or Windows Server 2008. For the recipes or
solutions that are specific to a particular version, we include a note mentioning the
version it is targeted for. In particular, because so much has changed since the intro‐
duction of Windows Server 2008 R2, the majority of our focus will be on Windows
Server 2008 R2 and later.
1.2. Where to Find the Tools
You’ll find a number of references to third-party command-line tools such as adfind,
admod, oldcmp, findexpacc, and memberof. These tools were developed by Microsoft
Directory Services MVP joe Richards, and he has made them available for free download
from his website. While these tools are not native to the Windows operating system,
they have become an invaluable addition to many Active Directory system adminis‐
trators’ toolkits, and we include them here to showcase their capabilities.
Once you have the tools at your disposal, there are a couple of other issues to be aware
of while trying to apply the solutions in your environment, which we’ll describe in the
following sections.
Running Tools with Alternate Credentials
A best practice for managing Active Directory is to create separate administrator ac‐
counts to which you grant elevated privileges, instead of letting administrators utilize
the user account to access other Network Operating System (NOS) resources. This is
beneficial because an administrator who wants to use elevated privileges has to log on
with his administrative account explicitly instead of having the rights implicitly, which
could lead to accidental changes in Active Directory. Assuming you employ this method,
you must provide alternate credentials when using tools to administer Active Directory
unless you log on to a machine, such as a domain controller, with the administrative
credentials.
There are several options for specifying alternate credentials. Many GUI and CLI tools
have an option to specify a user and password with which to authenticate. If the tool
you want to use does not have that option, you can use the runas command instead.
The following command will run the enumprop command under the credentials of the
administrator account in the adatum.com domain:
> runas /user:administrator@adatum.com
/netonly "enumprop "LDAP://dc1/dc=adatum,dc=com""
1.2. Where to Find the Tools | 3
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
29
|
You can also open a Windows command prompt using alternate credentials, which will
allow you to run commands using these elevated credentials until you close the com‐
mand prompt window. To open a command prompt using the runas command, simply
type runas /user:administrator@adatum.com cmd.
To run a Microsoft Management Console (MMC) with alternate credentials, simply use
mmc as the command to run from runas:
> runas /user:administrator@adatum.com /netonly "mmc"
This will create an empty MMC from which you can add consoles for any snap-ins that
have been installed on the local computer.
The /netonly switch is necessary if the user with which you are au‐
thenticating does not have local logon rights on the machine from which
you are running the command, such as a user ID from a nontrusted
domain.
There is another option for running MMC snap-ins with alternate credentials. In Win‐
dows Explorer, hold down the Shift key and then right-click on the tool you want to
open. If you select Run As Different User, you will be prompted to enter credentials
under which to run the tool.
Targeting Specific Domain Controllers
Another issue to be aware of when following the instructions in the recipes is whether
you need to target a specific domain controller. In the solutions in this book, we typically
do not target a specific domain controller. When you don’t specify a domain controller,
you are using a serverless bind, and there is no guarantee as to precisely which server
you will be hitting. Depending on your environment and the task you need to do, you
may want to target a specific domain controller so that you know where the query or
change will be taking place. Also, serverless binding can work only if the DNS for the
Active Directory forest is configured properly and your client can query it. If you have
a standalone Active Directory environment that has no ties to your corporate DNS, you
may need to target a specific domain controller for the tools to work.
1.3. Getting Familiar with LDIF
Native support for modifying data within Active Directory using a command-line tool
is relatively weak. The dsmod tool can modify attributes on a limited set of object classes.
One reason for the lack of native command-line tools to do this is that the command
line is not well suited for manipulating numerous attributes of an object simultaneously.
If you want to specify more than just one or two values that need to be modified, a single
4 | Chapter 1: Getting Started
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
30
|
command could get quite long. It would be easier to use a GUI editor, such as ADSI
Edit, to do the task instead.
The LDAP Data Interchange Format (LDIF) was designed to address this issue. Defined
in RFC 2849, LDIF allows you to represent directory additions, modifications, and
deletions in a text-based file, which you can import into a directory using an LDIFcapable tool.
The ldifde utility has been available since Windows 2000, and it allows you to import
and export Active Directory content in LDIF format. LDIF files are composed of blocks
of entries. An entry can add, modify, or delete an object. The first line of an entry is the
distinguished name. The second line contains a changetype, which can be add, modify,
or delete. If it is an object addition, the rest of the entry contains the attributes that
should be initially set on the object (one per line). For object deletions, you do not need
to specify any other attributes. And for object modifications, you need to specify at least
three more lines. The first should contain the type of modification you want to perform
on the object. This can be add (to set a previously unset attribute or to add a new value
to a multivalued attribute), replace (to replace an existing value), or delete (to remove
a value). The modification type should be followed by a colon and the attribute you
want to modify. The next line should contain the name of the attribute followed by a
colon and the value for the attribute. For example, to replace the last name attribute
with the value Smith, you’d use the following LDIF:
dn: cn=jsmith,cn=users,dc=adatum,dc=com
changetype: modify
replace: sn
sn: Smith
-
Modification entries must be followed by a line that contains only a hyphen (-). You can
add additional modification actions after the hyphen, each separated by another hyphen.
Here is a complete LDIF example that adds a jsmith user object and then modifies the
givenName and sn attributes for that object:
dn: cn=jsmith,cn=users,dc=adatum,dc=com
changetype: add
objectClass: user
samaccountname: jsmith
sn: JSmith
dn: cn=jsmith,cn=users,dc=adatum,dc=com
changetype: modify
add: givenName
givenName: Jim
-
replace: sn
sn: Smith
-
1.3. Getting Familiar with LDIF | 5
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
31
|
See Recipes 4.28 and 4.29 for more details on how to use the ldifde utility to import and
export LDIF files.
1.4. Replaceable Text
This book is filled with examples. Every recipe consists of one or more examples that
show how to accomplish a task. Most CLI- and PowerShell-based solutions use param‐
eters that are based on the domain, forest, OU, user, and so on, that is being added,
modified, queried, and so on. Instead of using fictitious names, in most cases we use
replaceable text. This text should be easily recognizable because it is in italics and sur‐
rounded by angle brackets (<>). Instead of describing what each replaceable element
represents every time we use it, we’ve included a list of some of the commonly used ones
here:
<DomainDN>
Distinguished name of the domain (e.g., dc=amer,dc=adatum,dc=com)
<ForestRootDN>
Distinguished name of the forest root domain (e.g., dc=adatum,dc=com)
<DomainDNSName>
Fully qualified DNS name of the domain (e.g., amer.adatum.com)
<ForestDNSName>
Fully qualified DNS name of the forest root domain (e.g., adatum.com)
<DomainControllerName>
Single-label or fully qualified DNS hostname of the domain controller (e.g.,
dc01.adatum.com)
<UserDN>
Distinguished name of the user (e.g., cn=administrator,cn=users,dc=ada
tum,dc=com)
<GroupDN>
Distinguished name of the group (e.g., cn=DomainAdmins,cn=users,dc=ada
tum,dc=com)
<ComputerName>
Single-label DNS hostname of the computer (e.g., adatum-xp)
1.5. Where to Find More Information
While it is our hope that this book provides you with enough information to perform
most of the tasks you need to do to maintain your Active Directory environment, it is
6 | Chapter 1: Getting Started
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
32
|
not realistic to think that we have covered every possible task. In fact, working on this
book has made us realize just how much Active Directory administrators need to know.
Now that Active Directory has been around for a number of years, a significant user
base has been built, which has led to other great resources of information. This section
contains some of the valuable sources of information that we use on a regular basis.
Command-Line Tools
If you have any questions about the complete syntax or usage information for any of
the command-line tools we use, you should first take a look at the help information for
the tools. The vast majority of CLI tools provide syntax information by simply pass‐
ing /? as a parameter. For example:
> dsquery /?
Microsoft Knowledge Base
The Microsoft Support website is a great source of information and is home to the
Microsoft Knowledge Base (MS KB) articles. Throughout the book, we include refer‐
ences to pertinent MS KB articles where you can find more information on the topic.
You can find the complete text for a KB article by searching on the KB number at
support.microsoft.com/default.aspx. You can also append the KB article number to the
end of this URL to go directly to the article: http://support.microsoft.com/kb/<Article‐
Number>.
Microsoft Developer Network
MSDN contains a ton of information on Active Directory and the programmatic in‐
terfaces to Active Directory, such as ADSI and LDAP. We sometimes reference MSDN
pages in recipes. Unfortunately, there is no easy way to reference the exact page we’re
talking about unless we provide the URL or navigation to the page, which would more
than likely change by the time the book is printed. Instead, we provide the title of the
page, which you can use to search on via msdn.microsoft.com/library.
1.5. Where to Find More Information | 7
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
33
|
Websites
While the Web is often changing, the following websites are a mainstay for Active
Directory−related material:
Microsoft Active Directory home page
This site is the starting point for Active Directory information provided by
Microsoft. It contains links to white papers, case studies, and tools.
Microsoft PowerShell home page
This site is the starting point for PowerShell information provided by Microsoft.
This will be an interesting site to keep an eye on as the various Microsoft product
groups release new and updated PowerShell support.
Microsoft forum for Directory Services on the Social Technet Microsoft forum site
This forum is a great place to ask a question and confer with other Active Directory
administrators and experts. It is frequented by some of the top Active Directory
experts in the business.
Microsoft webcasts
Webcasts are on-demand audio/video technical presentations that cover a wide
range of Microsoft products. There are several Active Directory−related webcasts
that cover such topics as disaster recovery, upgrading to Windows Server 2003
Active Directory, and Active Directory tools.
DirTeam blogs
The DirTeam collection of blogs features content from very active members of the
Directory Services MVP community.
joe Richards’ home page
This is the home of the joeware utilities that you’ll see referenced throughout this
book; you can always download the latest version of adfind, admod, and so on, from
joe’s site, as well as browse FAQs and forums discussing each utility.
Petri.co.il by Daniel Petri
This is another site that is run by a Microsoft MVP and that contains a number of
valuable links and tutorials.
Ask the Directory Services Team
This site features regularly updated content from members of the Directory Services
support organization within Microsoft.
ActiveDir home page
This is the home page for the ActiveDir Active Directory mailing list. It includes
links to Active Directory Services blogs, as well as articles, tutorials, and links to
third-party tools.
8 | Chapter 1: Getting Started
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
34
|
Directory Programming
Just as the ActiveDir list is crucial for AD administrators, this site is extremely
valuable for AD developers. It also includes user forums where participants can
post questions about AD programming topics.
Mailing List
ActiveDir
The ActiveDir mailing list is where the most advanced Active Directory questions
can get answered. The list owner, Tony Murray, does an excellent job of not allowing
topics to get out of hand (as can sometimes happen on large mailing lists). The list
is very active, and it is rare for a question to go unanswered. Some of Microsoft’s
Active Directory program managers and developers also participate on the list and
are very helpful with the toughest questions. Keeping track of this list is crucial for
any serious Active Directory administrator.
Additional Resources
In addition to the Resource Kit books, the following are good sources of information:
Active Directory, Fifth Edition, by Brian Desmond et al. (O’Reilly)
This is a good all-purpose book on Active Directory. A few of the topics the Fifth
Edition covers are new Windows Server 2012 features, designing Active Directory,
upgrading from Windows 2000, Active Directory Lightweight Directory Services
(AD LDS), Exchange 2013, and Active Directory automation.
The .NET Developer’s Guide to Directory Services Programming by Joe Kaplan and
Ryan Dunn (Addison-Wesley)
Written by two notables in the Directory Services programming community, this
book is a practical introduction to programming directory services, using both
versions 1.1 and 2.0 of the .NET Framework.
Windows IT Pro
This is a general-purpose monthly magazine for system administrators who support
Microsoft products. The magazine isn’t devoted to Active Directory, but generally,
related topics are covered every month.
1.5. Where to Find More Information | 9
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
35
| null |
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
36
|
CHAPTER 2
Forests, Domains, and Trusts
2.0. Introduction
To the layperson, the title of this chapter may seem like a hodgepodge of unrelated terms.
For the seasoned Active Directory administrator, however, these terms represent the
most fundamental and, perhaps, most important concepts within Active Directory. In
simple terms, a forest is a collection of data partitions and domains; a domain is a hi‐
erarchy of objects in a data partition that is replicated between one or more domain
controllers; and a trust is an agreement between two domains or forests to allow security
principals (i.e., users, groups, and computers) from one domain or forest to access
resources in the other domain or forest.
Active Directory domains are named using the Domain Name System (DNS) name‐
space. You can group domains that are part of the same contiguous DNS namespace
within the same domain tree. For example, the marketing.adatum.com, sales.ada‐
tum.com, and adatum.com domains are part of the adatum.com domain tree. A single
domain tree is sufficient for most implementations, but one example in which multiple
domain trees might be necessary is with large conglomerate corporations. Conglom‐
erates are made up of multiple individual companies in which each company typically
wants to maintain its own identity and, therefore, its own namespace. If you need to
support noncontiguous namespaces within a single forest, you will need to create mul‐
tiple domain trees. For example, adatum.com and treyresearch.com can form two sep‐
arate domain trees within the same forest.
Assuming that each company within the conglomerate wants its Active Directory do‐
main name to be based on its company name, you have two choices for setting up this
type of environment. You could either make each company’s domain(s) a domain tree
within a single forest, or you could implement multiple forests. One of the biggest dif‐
ferences between the two options is that all the domains within the forest trust each
other, whereas separate forests, by default, do not have any trust relationships set up
11
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
37
|
between them. Without trust relationships, users from one forest cannot access resour‐
ces located in the other forest. In our conglomerate scenario, if you want users in each
company to be able to access resources within their own domain, as well as the domains
belonging to other companies in the organization, using separate domain trees can
create an easier approach than separate forests. However, it’s important to keep in mind
when designing your network that forests form the security boundary for Active Di‐
rectory, as we’ll cover in the next section. This is because transitive trusts are established
between the root domains of each domain tree within a forest. As a result, every domain
within a forest, regardless of which domain tree it is in, is trusted by every other domain.
Figure 2-1 illustrates an example with three domain trees in a forest called adatum.com.
Figure 2-1. Multiple domain trees in a forest
Each domain increases the support costs of Active Directory due to the need for main‐
taining additional domain controllers, as well as the time you must spend configuring
and maintaining the domain. When designing an Active Directory forest, your goal
should be to keep the number of domains that you deploy to an absolute minimum.
Since the forest constitutes the security boundary for an Active Directory environment,
the minimalist approach toward the number of domains you use in an AD design be‐
comes all the more sensible.
With Windows 2000, if you implement the alternative approach and create multiple
Active Directory forests, you would have to create individual trusts between the domains
in every forest to create the fully trusted model. This can get out of hand pretty quickly
if there are numerous domains. Fortunately, with Windows Server 2003 and newer
versions, you can use a trust type called a cross-forest trust to create a single transitive
trust between two forest root domains. This single trust allows all of the domains in
both forests to fully trust one another.
12 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
38
|
There are many more issues to consider when deciding how many
forests, domains, and domain trees to implement. For a thorough ex‐
planation of Active Directory design considerations, we recommend
reading Active Directory, Fifth Edition, by Brian Desmond et al.
(O’Reilly).
In this chapter, we cover the most common tasks that you would need to do with forests,
domains, and trusts. First, we’re going to review how each item is represented within
Active Directory.
The Anatomy of a Forest
A forest is a logical structure that is a collection of one or more interconnected domains,
plus the configuration and schema naming contexts, as well as any application partitions
that have been configured. This means that all domains in a forest share a common
configuration and schema between them. Forests are considered the security boundary
in Active Directory; by this we mean that if you need to definitively restrict access to a
resource within a particular domain so that administrators from other domains do not
have any access to it whatsoever, you need to implement a separate forest instead of
using an additional domain within the current forest. This security concern is due to
the transitive trust relationship that exists between all domains in a forest, the writable
naming contexts (NCs) that exist on all domain controllers in a forest, and the extensive
rights and permissions that are granted to members of the Administrators group. In the
earliest days of Windows 2000 Active Directory, Microsoft advocated an “empty forest
root” design with the intention of protecting the enterprise-wide security principals in
the forest root domain from being accessible by domain administrators in the child
domains. However, subsequent discoveries have indicated that it is in fact the forest,
not the domain, that truly provides security separation between distinct groups of re‐
sources and administrators.
Active Directory relies on naming contexts to divide the AD database into separate
partitions, each of which contains information that is replicated together as a logical
unit. At a minimum, an Active Directory forest consists of three naming contexts: the
Domain NC for the forest root domain, the Configuration NC, and the Schema NC.
Here is a description of the types of partitions that can be part of a forest:
Configuration NC
This contains data that is applicable across all domains in a forest, and thus is re‐
plicated to all domain controllers in the forest. Some of this data includes the site
topology, list of partitions, published services, display specifiers, and extended
rights.
2.0. Introduction | 13
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
39
|
Schema NC
This contains the objects that describe how data can be structured and stored in
Active Directory. The classSchema objects in the Schema NC represent class
definitions for objects. The attributeSchema objects describe what data can be
stored with classes. The Schema NC is replicated to all domain controllers in a
forest.
Domain NC
A domain is a naming context that holds domain-specific data, including user,
group, and computer objects. This forms a collection of objects that is replicated
between one or more domain controllers.
Application partitions
These are configurable partitions that can be rooted anywhere in the forest and can
be replicated to any domain controller in the forest, or to a subset of domain con‐
trollers. These are not available with Windows 2000.
The Partitions container in the Configuration NC contains the complete list of all
partitions associated with a particular forest.
The Anatomy of a Domain
Although forests constitute the security boundary in an Active Directory environment,
you can split up your AD infrastructure into separate domains to create smaller ad‐
ministrative or replication boundaries within a large-scale network. In Active Directory,
domains can also constitute a policy boundary, as certain Group Policy settings such as
password policies and account lockout policies can be applied only to domain user
accounts at the domain level. However, Windows Server 2008 introduced the concept
of a Fine-Grained Password Policy, which allows administrators to configure multiple
password and account lockout policies within a single domain.
Domains are represented in Active Directory by domainDNS objects. The distinguished
name (DN) of a domainDNS object directly corresponds to the fully qualified DNS name
of the domain. For example, the amer.adatum.com domain would have a DN of
dc=amer,dc=adatum,dc=com.
In Active Directory, each domain is a naming context and is also represented under the
Partitions container in the Configuration NC as a crossRef object, which allows each
domain controller in a forest to be aware of every partition in the forest and not just
those that are held by one particular DC. In this case, the relative distinguished name
(RDN) of the crossRef object is the NetBIOS name of the domain as defined by the
netBIOSName attribute of the domain object.
In our previous example of amer.adatum.com, the corresponding crossRef object for
the domain (assuming the forest name was adatum.com) would be located at
cn=AMER,cn=Partitions,cn=Configuration,dc=adatum,dc=com.
14 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
40
|
The Anatomy of a Trust
Microsoft has relied on trust relationships to provide resource access across domain
boundaries since the early days of Windows NT. Before Active Directory, all trust re‐
lationships were one-way and nontransitive in nature. A one-way trust relationship, as
the name suggests, enables resource access only in a single direction: a single trust
relationship will enable resource access only from DomainA to DomainB, but a separate
trust would need to be created to enable access in the other direction. A nontransitive
trust relationship means that if you create a trust from DomainA to DomainB and a
second one from DomainB to DomainC, DomainA does not trust DomainC by default.
This one-way nontransitive trust relationship was the only type that was available in
Windows NT. Active Directory improved on this by automatically creating two-way
transitive trust relationships between every parent and child domain in a domain tree,
and between the root domains of all trees in every forest. Thus, all of the domains in a
forest effectively trust all of the other domains in the forest.
Trusts are stored as trustedDomain objects within the System container of a domain.
Table 2-1 lists some of the important attributes of trustedDomain objects.
Table 2-1. Attributes of trustedDomain objects
Attribute Description
cn Relative distinguished name of the trust. This is the name of the target
domain that is trusted. For Windows NT domains, it is the NetBIOS
name. For Active Directory domains, it is the DNS name.
trustDirection Flag that indicates whether the trust is disabled, inbound, outbound,
or both inbound and outbound.
See Recipes 2.18 and 2.19 for more information.
trustType Flag that indicates if the trust is to a down-level (NT4), up-level
(Windows 2000 or later), or Kerberos (e.g., MIT) domain. See
Recipe 2.18 for more information.
trustAttributes Contain miscellaneous properties that can be enabled for a trust. See
Recipe 2.18 for more information.
trustPartner The name of the trust partner. See Recipe 2.18 for more information.
A trust also has a corresponding user object in the Users container of a domain. This
is where the trust password is stored. The RDN of this user object is the same as the cn
attribute for the corresponding trustedDomain object with a $ appended.
2.1. Creating a Forest
Problem
You want to create a new forest by creating a new forest root domain.
2.1. Creating a Forest | 15
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
41
|
Solution
Using a graphical user interface
On a Windows Server 2008 R2 computer:
1. Open the Server Manager utility. In the lefthand pane, click Roles.
2. In the righthand pane, click Add Roles.
3. Click Next. Place a checkmark next to Active Directory Domain Services.
4. Click Next, click Add Required Features if applicable, click Next twice, and then
click Install.
5. Click Close and then click the Active Directory Domain Services link in the left
pane.
6. In the righthand pane, click the “Run the Active Directory Domain Services
Installation Wizard (dcpromo.exe)” link.
7. Click Next twice to continue. Click the “Create a new domain in a new forest” radio
button and click Next.
8. Follow the rest of the configuration steps to complete the wizard.
On a Windows Server 2012 computer:
1. Add the Active Directory Domain Services role. After the role installation, a noti‐
fication will appear within Server Manager.
2. Click Notifications, and then click “Promote this server to a domain controller.”
3. The Active Directory Domain Services Configuration Wizard will appear.
4. Click “Add a new forest.”
5. Enter the root domain name and then click Next.
6. Select the forest and domain functional levels or leave the defaults of Windows
Server 2012.
7. Confirm the options to install a DNS server and a global catalog server (not optional
for a new forest and a new forest root domain).
8. Enter the Directory Services Restore Mode (DSRM) password and then click Next.
9. Specify the DNS delegation creation, if necessary, and then click Next.
10. Verify the NetBIOS domain name and then click Next.
11. Specify the location of the database, or accept the defaults, and then click Next.
16 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
42
|
12. Review the selections given while using the wizard. Optionally, click “View script”
to see the PowerShell command and then click Next.
13. After the prerequisites have been successfully validated, click Install to begin the
process. After promotion, the server will automatically reboot.
Using PowerShell
The Install-ADDSForest cmdlet is used to create a new forest, as shown in the following
examples. The first example installs a new forest, a new forest root domain, and DNS.
> Install-ADDSForest -DomainName <DomainName> -InstallDNS
The following example installs a new forest, installs a new forest root domain, sets the
file locations, sets the domain and forest functional levels, and installs DNS.
> Install-ADDSForest -DatabasePath "D:\ADDS\DB" -DomainMode "Win2012"↵
-DomainName <DomainName> -DomainNetBIOSName <NetBIOSName> -ForestMode↵
"Win2012" -InstallDNS:$true -LogPath "E:\ADDS\logs" -SYSVOLPath↵
"F:\ADDS\SYSVOL" -Force:$true
Discussion
The act of creating a forest consists of creating a forest root domain. To do this, you
need to promote a Windows Server 2008 R2 or Windows Server 2012 server to be a
domain controller for a new domain. When using the GUI method, the promotion
process has a wizard interface that requires you to answer several questions about the
forest and domain into which you want to promote the server. After it finishes, you will
be asked to reboot the computer to complete the promotion process. When using the
PowerShell method, the only information needed after running the PowerShell com‐
mand is the desired Directory Services Restore Mode (DSRM) password.
As you have probably noticed since Windows Server 2008, Microsoft has changed the
nomenclature surrounding Active Directory. What used to simply be called “Active
Directory” is now “Active Directory Domain Services,” as a number of other server
services have been rebranded under the Active Directory umbrella, including Active
Directory Certificate Services, Active Directory Rights Management Services, Active
Directory Federated Services, and Active Directory Lightweight Directory Services.
See Also
“Install a New Windows Server 2012 Active Directory Forest (Level 200)”; Recipe 3.7
for automating the promotion of a domain controller; MS KB 238369 (How to Promote
and Demote Domain Controllers in Windows 2000); MS KB 324753 (How to Create
an Active Directory Server in Windows Server 2003)
2.1. Creating a Forest | 17
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
43
|
2.2. Removing a Forest
Problem
You want to tear down a forest and decommission any domains contained within it
because you no longer need it.
Solution
To remove a forest, you need to demote all the domain controllers in the forest. When
you demote an existing domain controller, you will be given the option to demote the
machine to a member server (unless the domain controller is the last domain controller
in the domain, in which case the server will become part of a workgroup instead). After
that is completed, and depending on how your environment is configured, you may
need to remove WINS and DNS entries that were associated with the domain controllers
and domains, unless they were automatically removed via WINS deregistration and
dynamic DNS (DDNS) during demotion. The following commands can help determine
if all entries have been removed:
> netsh wins server \\<WINSServerName> show name <DomainNetBiosName> 1b
> netsh wins server \\<WINSServerName> show name <DomainNetBiosName> 1c
> nslookup <DomainControllerDNSName>
> nslookup -type=SRV _ldap._tcp.dc._msdcs.<ForestDNSName>
> nslookup <ForestDNSName>
You should run the first two commands for every domain in the forest
if the forest contained more than one. The preceding list is not meant
to be exhaustive, so be sure to check DNS across all domains and watch
for entries for RODCs, if the domain controller that was demoted was
an RODC.
Discussion
The method described in this solution is the graceful way to tear down a forest. You can
also use a brute-force method to remove a forest by simply reinstalling the operating
system on all domain controllers in the forest. This method is not recommended except
in lab or test environments. You’ll also need to make sure any DNS resource records for
the domain controllers are removed from your DNS servers since the domain control‐
lers will not dynamically remove them like they do during the demotion process.
You will also want to remove any trusts that have been established for the forest (see
Recipe 2.21 for more details). For more information on how to demote a domain con‐
troller, see Recipe 3.6.
18 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
44
|
To fully remove all traces of an Active Directory forest in Windows
Server 2008 and later, you should also remove the Active Directory
Domain Services role that has been installed on any of the domain con‐
trollers. This will remove the actual system files associated with the AD
DS server role. You may also want to remove any associated infrastruc‐
ture roles from the servers in question, such as the DNS server role or
the WINS server role. If you need to forcibly remove a single domain
from an AD forest, you can also use the ntdsutil command-line utility;
see Recipe 2.4 for more information.
See Also
Recipe 2.18 for viewing the trusts for a domain; Recipe 2.21 for removing a trust;
Recipe 3.6 for demoting a domain controller
2.3. Creating a Domain
Problem
You want to create a new domain that may be part of an existing domain tree or the root
of a new domain tree.
Solution
Using a graphical user interface
On Windows Server 2008 R2, add the Active Directory Domain Services role and then
run dcpromo from a command line. Place a checkmark next to “Use advanced mode
installation.” You can then select one of the following:
• Existing forest
— Create a new domain in an existing forest
— Create a new domain tree root instead of a new child domain
• Create a new domain in a new forest
On Windows Server 2012, add the Active Directory Domain Services role. After the
role installation completes, a notification will appear within Server Manager. Click
Notifications and then click “Promote this server to a domain controller.” The Active
Directory Domain Services Configuration Wizard appears. Select the desired deploy‐
ment operation (“Add a domain controller to an existing domain,” “Add a new domain
to an existing forest,” or “Add a new forest”). Then, configure the remaining options in
the wizard to complete the process.
2.3. Creating a Domain | 19
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
45
|
Using PowerShell
The Install-ADDSDomain cmdlet is used to create a new domain. The following example
installs a new child domain in an existing forest and installs DNS:
> Install-ADDSDomain -NewDomainName <newdomainname> -ParentDomainName↵
contoso.com; -DomainMode Win2012 -DomainType ChildDomain -InstallDNS:$true↵
-NewDomainNetBiosName <newNetBIOSname>
Note that the Install-ADDSDomain cmdlet is available only if the Active Directory Do‐
main Services role has been installed on the server where the cmdlet will be run.
Discussion
The options to create a new domain allow you a great deal of flexibility in creating an
Active Directory infrastructure that maps to your organization’s business requirements.
You can add a new domain to an existing domain tree, or else create a new domain tree
entirely. If you want to create a new domain that is a child domain of a parent
domain (for example, contained within the same contiguous namespace), then you are
creating a domain in an existing domain tree. If you are creating the first domain in a
forest or a domain that is outside the namespace of the forest root, then you are creating
a domain in a new domain tree. For example, if you have already created the treyre‐
search.com domain and then you install the first DC in the amer.treyresearch.com do‐
main, then amer.treyresearch.corp is a child domain. Conversely, if you want to create a
domain that is part of the treyresearch.com forest but uses an entirely different naming
convention (such as treyresearchasia.com), then you are creating a new domain tree
within an existing forest.
See Also
Recipe 3.1 for promoting a domain controller; Recipe 3.7 for automating the promotion
or demotion of a domain controller
2.4. Removing a Domain
Problem
You want to remove a domain from a forest. You may need to remove a domain during
test scenarios or if you are collapsing or reducing the number of domains in a forest.
Solution
Removing a domain consists of demoting each domain controller in the domain, which
can be accomplished by running the Remove Roles and Features Wizard on the domain
controllers and following the steps to demote the domain controllers. For the last
20 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
46
|
domain controller in the domain, be sure to select the “Last domain controller in the
domain” option in the wizard so that the objects associated with the domain get re‐
moved. If you do not select this option for the last domain controller in the domain,
take a look at Recipe 2.5 for how to remove an orphaned domain.
If the domain you want to remove has child domains, you must remove
the child domains before proceeding.
You can also demote domain controllers by using PowerShell, as shown in the following
example:
> Uninstall-ADDSDomainController -LastDomainControllerInDomain↵
-RemoveApplicationPartitions
In the preceding example, two optional parameters have been specified. The
-LastDomainControllerInDomain parameter is used when demoting the last domain
controller, while the -RemoveApplicationPartitions parameter should be specified to
delete all data associated with any application partitions in the domain.
After all domain controllers have been demoted, depending on how your environment
is configured you may need to remove any WINS and DNS entries that were associated
with the domain controllers and domain that were automatically removed via WINS
deregistration and DDNS during the demotion process. The following commands can
help determine if all entries have been removed:
> netsh wins server \\<WINSServerName> show name <DomainNetBiosName> 1b
> netsh wins server \\<WINSServerName> show name <DomainNetBiosName> 1c
> nslookup <DomainControllerName>
> nslookup -type=SRV _ldap._tcp.dc._msdcs.<DomainDNSName>
> nslookup <DomainDNSName>
You will also want to remove any trusts that have been established for the domain (see
Recipe 2.21 for more details). For more information on how to demote a domain con‐
troller, see Recipe 3.6.
Discussion
The brute-force method for removing a forest, as described in the discussion for
Recipe 2.2, is not a good method for removing a domain. Doing so will leave all of the
domain controller and server objects, along with the domain object and associated
domain naming context, hanging around in the forest. If you used that approach, you
would eventually see numerous replication and file replication service errors in the event
log caused by failed replication events from the nonexistent domain. You would need
to remove the metadata associated with the removed domain using ntdsutil to correct
these errors.
2.4. Removing a Domain | 21
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
47
|
To fully remove all traces of an Active Directory forest in Windows Server 2008 and
later, you should also remove the Active Directory Domain Services role that has been
installed on any of the Windows Server 2008 or later domain controllers. This will
remove the actual system files associated with the AD DS server role. You may also want
to remove any associated infrastructure roles from the servers in question, such as the
DNS server role or the WINS server role.
See Also
Recipe 2.2; Recipe 2.5; Recipe 2.18 for viewing the trusts for a domain; Recipe 2.21 for
removing a trust; Recipe 3.6 for demoting a domain controller; and TechNet for details
on removing Active Directory Domain Services
2.5. Removing an Orphaned Domain
Problem
You want to completely remove a domain that was orphaned because the domain was
forcibly removed, or the last domain controller in the domain failed or was otherwise
decommissioned improperly.
Solution
Using a command-line interface
The following commands will forcibly remove an orphaned domain from a forest. Re‐
place <DomainControllerName> with the hostname of the Domain Naming Master
Flexible Single Master Operation (FSMO; pronounced fiz-mo) for the forest.
1 NTDSUTIL
2 metadata cleanup
3 connections
4 connect to server <DomainControllerName>
5 quit
6 select operation target
7 list sites
8 select site <# of site>
9 list servers in site
10 select server <# of domain controller>
11 list domains
12 select domain <# of domain>
13 quit
14 remove selected server (confirm when prompted)
15 list naming context
16 select naming context <# of the DNS Naming Context>
17 quit
18 remove selected naming context (confirm when prompted)
22 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
48
|
19 select operation target
20 list naming context
21 select naming context <# of the domain DN>
22 quit
23 remove selected naming context (confirm when prompted)
Discussion
Removing an orphaned domain consists of removing the domain object for the domain
(e.g., dc=emea,dc=adatum,dc=com), all of its child objects, and the associated cross
Ref object in the Partitions container. You need to target the Domain Naming FSMO
when using ntdsutil because that server is responsible for creation and removal of
domains.
Before you can use ntdsutil to remove an orphaned domain, you must first forcibly
remove any domain controllers in that domain that were not gracefully demoted. (For‐
cibly removing individual domain controllers will be discussed in Chapter 3.) You must
also remove the DomainDNSZones application partition associated with the orphaned
domain, if this was not gracefully removed. (Forcibly removing the DomainDNSZones
application partition will be discussed in Chapters 13 and 17.)
See Also
Recipe 3.10 for removing an unsuccessfully demoted domain controller; MS KB 230306
(How to Remove Orphaned Domains from Active Directory); MS KB 251307 (How to
Remove Orphaned Domains from Active Directory Without Demoting the Domain
Controllers); MS KB 255229 (Dcpromo Demotion of Last Domain Controller in Child
Domain Does Not Succeed); Chapter 3 for information on performing a metadata
cleanup of individual domain controllers; Chapters 13 and 17 for information on man‐
ually removing the DomainDNSZones application partition
2.6. Finding the Domains in a Forest
Problem
You want a list of all domains in an Active Directory forest.
Solution
Using a graphical user interface
Open the Active Directory Domains and Trusts snap-in (domain.msc). The list of the
domains in the default forest can be browsed in the left pane.
2.6. Finding the Domains in a Forest | 23
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
49
|
Using PowerShell
You can retrieve this information using the Get-ADForest command, as shown here:
> Get-ADForest | Select Domains
Discussion
Using a graphical user interface
If you want to view the domains for a forest other than the one you are logged in to,
right-click on Active Directory Domains and Trusts in the left pane and select Change
Forest. Enter the forest root domain name in which you want to browse. In the left pane,
expand the forest root domain to see any subdomains.
Using PowerShell
In the PowerShell solution, we are relying on the Active Directory module. The GetADForest cmdlet has been available since Windows Server 2008 R2 and the usage
remains identical in Windows Server 2012.
See Also
Recipe 3.12 for finding the domain controllers for a domain
2.7. Finding the NetBIOS Name of a Domain
Problem
You want to find the NetBIOS name of a domain. Although Windows primarily uses
DNS for name resolution, the NetBIOS name of a domain is still important. Some users
still rely on the NetBIOS name to log on to a domain or to applications by using the
down-level logon name. The down-level logon name uses the <domainname>\<user
name> format.
Solution
Using a graphical user interface
1. Open the Active Directory Users and Computers snap-in.
2. Right-click the domain you want to view in the left pane and select Properties.
The NetBIOS name will be shown in the “Domain name (pre-Windows 2000)” field.
24 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
50
|
You can also retrieve this information by using the Active Directory Administrative
Center, as follows:
1. Open the Active Directory Administrative Center.
2. Right-click the domain in the left pane and then select Properties. The NetBIOS
name will be shown in the “Pre-Windows 2000 domain name” field.
Using a command-line interface
To find the NetBIOS name of a Windows domain, use the following command while
logged on as a domain user from a computer joined to the domain:
> set userdomain
Using PowerShell
In a single-domain environment, run the following command:
> Get-ADDomain | FL NetBIOSName
In a multidomain environment, run the following command:
> Get-ADDomain -identity <domainname> | FL NetBIOSName
Discussion
Obtaining the NetBIOS name of a domain is easier today than it was before the intro‐
duction of the Active Directory module for Windows PowerShell. Prior to the module,
third-party PowerShell modules had to be used, and the solution was a multiline Pow‐
erShell script. Today, we have the Get-ADDomain cmdlet, which outputs 29 properties.
Running the Get-ADDomain cmdlet without specifying the desired property will show
the output with all 29 properties.
The NetBIOS name of a domain is often referred to with alternative names. In the
command-line example in this recipe, Windows uses the USERDOMAIN environment
variable to store the NetBIOS name of the domain to which the user logged on. By
running just the set command, you can display all of the Windows environment vari‐
ables. This can be helpful when you need to find out if specific information is already
stored within an environment variable.
2.8. Renaming a Domain
Problem
You want to rename a domain—for example, due to organizational changes, due to legal
restrictions, or because of a merger, acquisition, or divestiture. Renaming a domain is
2.8. Renaming a Domain | 25
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
51
|
a very involved process and should be done only when absolutely necessary. Changing
the name of a domain can have an impact on everything from DNS, replication, and
GPOs to DFS and Certificate Services. A domain rename also requires rebooting all
domain controllers, member servers, and client computers in the domain!
Solution
A domain rename procedure is supported if a forest is running Windows Server 2003
domain controllers or later and is at the Windows Server 2003 forest functional level or
later. Microsoft provides a rename tool (rendom.exe) that is used for the process. Here
are the commands for a domain rename in Server 2012:
1 rendom /list (this command will produce a file named DomainList.xml)
2 Edit DomainList.xml (Change the domain name to the desired name.)
3 rendom /upload
4 rendom /prepare
5 rendom /execute
6 gpfixup /olddns:adatum.com /newdns:contoso.com
7 gpfixup /oldnb:adatum /newnb:contoso
8 rendom /end
We highly recommend reading additional material on TechNet before attempting the
procedure, as well as attempting the procedure in a test lab before performing it against
a production environment.
Discussion
The domain rename process can accommodate very complex changes to your domain
model. You can perform the following types of renames:
• Rename a domain to a new name without repositioning it in the domain tree.
• Reposition a domain within a domain tree.
• Create a new domain tree with a renamed domain.
One thing you cannot do with the domain rename procedure is to reposition the forest
root domain. You can rename the forest root domain, but you cannot change its status
as the forest root domain. Another important limitation to note is that you cannot
rename any domain in a forest that has had Exchange 2007 or Exchange 2010 installed,
though an environment with Exchange Server 2003 SP1 is capable of handling domain
renames. The rendom.exe utility also includes the gpfixup.exe utility, which corrects
references to Group Policy objects after the domain name changes. When working with
Exchange 2003, you can also use the xdr-fixup tool to correct Exchange attributes to
match the new domain name.
26 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
52
|
See Also
“Introduction to Administering Active Directory Domain Rename”
2.9. Raising the Domain Functional Level to Windows
Server 2012
Problem
You want to change the functional level of a Windows Server 2008 R2 Active Directory
domain to the Windows Server 2012 functional level.
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. Browse to the domain you want to change in the left pane.
3. Right-click on the domain and select Properties. The current level will be shown in
the dialog box.
4. To change the level, click the Raise button at the bottom.
Using PowerShell
To change the functional level, use the Set-ADDomainMode cmdlet:
> Set-ADDomainMode -Identity <DomainDNSName> -DomainMode Windows2012
Discussion
Since Windows Server, Active Directory functional levels have replaced the domain
mode that was used in Windows 2000 to signify what operating systems are allowed to
run on the domain controllers in the domain. With Windows Server 2003 and later,
there are functional levels for both domains and forests, whereas with Windows 2000,
the domain mode applied only to domains. The msDS-Behavior-Version attribute of
the domainDNS object (e.g., dc=amer,dc=adatum,dc=com) holds the current domain
functional level. Table 2-2 shows the six functional levels, their associated msDSBehavior-Version values, and the operating systems that can be used on domain con‐
trollers in each.
2.9. Raising the Domain Functional Level to Windows Server 2012 | 27
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
53
|
Table 2-2. Active Directory domain functional levels
Functional level msDS-Behavior-Version Valid operating systems for domain controllers
Windows Server 2003 2 Windows Server 2003 and later
Windows Server 2008 3 Windows Server 2008 and later
Windows Server 2008 R2 4 Windows Server 2008 R2 and later
Windows Server 2012 5 Windows Server 2012
Various new features of Active Directory are enabled with each domain functional level.
See Active Directory, Fifth Edition, by Brian Desmond et al. (O’Reilly) for more details.
The value contained in msDS-Behavior-Version is mirrored in the attribute domain
Functionality of the RootDSE. That means you can perform anonymous queries
against the RootDSE of a domain to quickly determine its current functional level.
One of the benefits of the GUI solution is that if a problem is encoun‐
tered, you can save and view the output log, which will contain infor‐
mation on any errors that were found.
See Also
“Raise the Domain Functional Level”
2.10. Raising the Functional Level of a Windows Server
2008 or 2008 R2 Forest
Problem
You want to raise the functional level of a forest to Windows Server 2012. You should
raise the functional level to take advantage of the new features and enhancements avail‐
able in the latest functional level.
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. In the left pane, right-click on Active Directory Domains and Trusts and select Raise
Forest Functional Level.
28 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
54
|
3. Ensure that “Windows Server 2012” is displayed in the available forest functional
level drop-down list and then click Raise. A warning dialog box will appear that
mentions that the process may not be reversible. Click OK to proceed.
After a few seconds, you should see a message stating whether the operation was
successful.
Using PowerShell
To retrieve the current forest functional level, run the following command:
> Get-ADForest | FL Name,ForestMode
Discussion
The Windows Server 2012 forest functional level is very similar to a domain functional
level. Even if just one of the domains in the forest is at the domain functional level of
Windows Server 2008 R2, you cannot raise the forest above the Windows Server 2008
R2 forest functional level. If you attempt to do so, you will receive an error that the
operation cannot be completed. After you raise the last Windows Server 2008 R2 domain
functional level to Windows Server 2012, you can then raise the forest functional level
as well.
You may be wondering why there is a need to differentiate between forest and domain
functional levels. The primary reason is new features. Some new features of Windows
Server 2008 R2 require that all domain controllers in the forest are running the appro‐
priate operating system. To ensure that all domain controllers are running a certain
operating system throughout a forest, Microsoft had to apply the functional-level con‐
cept to forests as well as domains. Windows Server 2012 requires a minimum forest
functional level of Windows Server 2003. The Windows Server 2012 forest functional
level does not offer any new features, although the Windows Server 2012 domain func‐
tional level does offer a couple of new Kerberos authentication options.
The forest functional level is stored in the msDS-Behavior-Version attribute of the
Partitions container in the Configuration NC. For example, in the adatum.com forest,
it would be stored in cn=partitions,cn=configuration,dc=adatum,dc=com. The val‐
ue contained in msDS-Behavior-Version is mirrored to the forestFunctionality
attribute of the RootDSE, which means you can find the functional level of the forest
by querying the RootDSE.
One of the benefits of the GUI solution is that if a problem occurs, you
can save and view the output log, which will contain information on
any errors that were encountered.
2.10. Raising the Functional Level of a Windows Server 2008 or 2008 R2 Forest | 29
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
55
|
See Also
“Upgrade Domain Controllers to Windows Server 2012” for information about the
forest and domain functional levels and other prerequisites; Recipe 2.11 for preparing
a forest with AdPrep
2.11. Using AdPrep to Prepare a Domain or Forest for
Windows Server 2012
Problem
You want to upgrade your existing Active Directory domain controllers to Windows
Server 2012.
Solution
You can run the AdPrep tool, which extends the schema and adds several objects in
Active Directory. For instance, to prepare a domain or forest for a Windows Server 2012
upgrade, you can first run the following command on the Schema FSMO with the
credentials of an account that is in both the Enterprise Admins and Schema Admins
groups:
> adprep /forestprep
After the updates from /forestprep have replicated throughout the forest (see
Recipe 2.10), run the following command on the Infrastructure FSMO in each domain
with the credentials of an account in the Domain Admins group:
> adprep /domainprep
If the updates from /forestprep have not replicated to at least the Infrastructure FSMO
servers in each domain, an error will be returned when running /domainprep. To debug
any problems you encounter, check out the AdPrep logfiles located at %SystemRoot%
\System32\Debug\Adprep\Logs.
AdPrep can be found in the \support\adprep directory on the Windows
Server 2012 installation media. The tool relies on several files in that
directory, so you cannot simply copy that file out to a server and run it.
You must run it from a CD or from a location where the entire directory
has been copied.
To prepare to add the first Windows Server 2012 domain controller to an existing do‐
main, you will need to run the version of AdPrep contained on Windows Server 2012
installation media. The preparation also includes a third AdPrep switch that will update
30 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
56
|
permissions on existing Group Policy Objects (GPOs) to allow for updated functionality
in the Group Policy Management Console (GPMC):
> adprep /domainprep /gpprep
The Windows Server 2012 preparation, in addition to /forestprep, /domainprep,
and /domainprep /gpprep, also includes /rodcprep to allow for the installation of
Read-Only Domain Controllers (RODCs), which we will discuss in Chapter 3.
Discussion
The adprep command prepares a forest and domains for Windows Server 2012.
Both /forestprep and /domainprep must be run before you can upgrade any domain
controllers to Windows Server 2012 or install new Windows Server 2012 domain
controllers.
The adprep command serves a similar function to the Exchange 2010 setup /forest
prep and /domainprep commands, which prepare an Active Directory forest and do‐
mains for Exchange 2010. The adprep /forestprep command extends the schema and
modifies some default security descriptors, which is why it must run under the creden‐
tials of someone in both the Schema Admins and Enterprise Admins groups. In addition,
the adprep /forestprep and /domainprep commands add new objects throughout the
forest.
Although not mandatory, it is helpful to run /domainprep from the
server hosting the Infrastructure Master FSMO since this is the DC that
controls the /domainprep process.
See Also
Recipe 2.10; Recipe 2.12 for determining whether AdPrep has completed; the Microsoft
TechNet site for information about the Windows Server 2008 AdPrep process
2.12. Determining Whether AdPrep Has Completed
Problem
You want to determine whether the AdPrep process, described in Recipe 2.11, has
successfully prepared a domain or forest for Windows Server 2012. After AdPrep has
completed, you will then be ready to start promoting Windows Server 2012 domain
controllers.
2.12. Determining Whether AdPrep Has Completed | 31
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
57
|
Solution
To determine whether adprep /forestprep has completed for a Windows Server 2012
upgrade, run ADSI Edit and then follow these steps:
1. In the left pane, right-click on ADSI Edit and then click Connect To.
2. In the Connection Settings window, click the “Select a well known Naming Context”
radio button and then click Schema.
3. In the left pane, double-click “Schema [<FQDN of domain controller>]”.
4. Right-click the DN of the schema and then click Properties.
5. Read the value of the objectVersion attribute. If the objectVersion attribute
shows a value of 56, then the adprep /forestprep command completed
successfully.
To determine whether adprep /domainprep has completed for a Windows Server 2012
upgrade, run ADSI Edit and then follow these steps:
1. In the left pane, right-click on ADSI Edit and click Connect To.
2. In the Connection Settings window, click the “Select a well known Naming Context”
radio button, and then click “Default naming context.”
3. In the left pane, double-click “Default naming context [<FQDN of domain
controller>].”
4. Expand the DN of the domain.
5. Expand the CN=System container.
6. Expand the CN=DomainUpdates container.
7. Right-click on CN=ActiveDirectoryUpdate and then click Properties.
8. Read the value of the revision attribute. If the revision attribute has a value of 9,
then the adprep /domainprep command completed successfully.
32 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
58
|
Discussion
As described in Recipe 2.11, the AdPrep utility is used to prepare an Active Directory
forest for the upgrade to Windows Server 2012. One of the nice features of AdPrep is
that it stores its progress in Active Directory. For /forestprep, the objectVersion
attribute of the schema indicates the level of the forest. For /domainprep, a container
with a distinguished name of cn=DomainUpdates,cn=System,<DomainDN> is created.
After all of the operations have completed successfully, the objectVersion attribute
should show a value of 56 (see Figure 2-2).
Figure 2-2. ADSI Edit showing the objectVersion attribute of an AD DS forest that was
updated to Windows Server 2012 by running adprep /forestprep
For /domainprep, a container with a distinguished name of cn=ActiveDirectoryUp
date,cn=DomainUpdates,cn=System,<DomainDN> is created. After all of the operations
have completed successfully, the revision attribute of the ActiveDirectoryUpdate
object should show a value of 9 (see Figure 2-3).
2.12. Determining Whether AdPrep Has Completed | 33
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
59
|
Figure 2-3. ADSI Edit showing the revision attribute of an AD DS domain that was
updated to Windows Server 2012 by running adprep /domainprep
See Also
Recipe 2.11 for running AdPrep; the Microsoft TechNet site for additional information
about the Windows Server 2012 AdPrep process
2.13. Checking Whether a Windows Domain Controller
Can Be Upgraded to Windows Server 2003 or 2008
Problem
You want to determine whether a domain controller is ready to be upgraded to Windows
Server 2003 or Windows Server 2008.
Solution
Using a graphical user interface
For Windows Server 2008, Windows Server 2008 R2, and Windows Server 2012, down‐
load and run the Microsoft Assessment and Planning Solution Accelerator from the
Microsoft website, which will generate upgrade readiness reports to help your
34 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
60
|
organization prepare for an upgrade to Windows Server 2008, Windows Server 2008
R2, and Windows Server 2012.
Discussion
Prior to Windows Server 2008, the WINNT32 command with the /checkupgradeon
ly switch could be used to assess whether a domain controller could be upgraded.
Windows Server, since 2008, has eliminated the /checkupgradeonly switch in the in‐
stallation media, instead opting to provide a free inventory and analysis tool in the form
of the Microsoft Assessment and Planning (MAP) tools.
See Also
“Microsoft Assessment and Planning Toolkit”
2.14. Creating an External Trust
Problem
You want to create a one-way or two-way nontransitive trust from an AD domain to a
Windows NT domain, or to a domain within an untrusted Active Directory forest.
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. In the left pane, right-click the forest root domain and select Properties.
3. Click on the Trusts tab.
4. Click the New Trust button. Then click Next.
5. Enter the name of the domain and then click Next.
6. Verify that External trust is selected and then click Next.
7. Verify that a two-way trust direction is selected and then click Next.
8. Verify that “This domain only” is selected to create the trust and then click Next.
9. Verify that “Domain-wide authentication” is selected and then click Next.
10. Enter a complex password for the trust password and then click Next. Note that the
password must meet the domain password policy.
11. Review the trust settings summary and then click Next.
2.14. Creating an External Trust | 35
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
61
|
12. A message indicating that the trust relationship was created successfully will appear.
Click Next to configure the new trust.
13. Perform the same steps on the trusted domain. Then, on both sides, select Yes to
confirm the incoming trust and then click Next.
14. A success message will appear. Click Finish.
15. A message will appear from AD DS that mentions that security identifier (SID)
filtering is enabled. Click OK.
The external trust should now appear in the Trusts tab of the domain properties.
Using a command-line interface
> netdom trust TrustingDomainName/d:TrustedDomainName/add
For example, to create a trust from the NT4 domain ADATUM_NT4 to the AD domain
ADATUM, use the following command:
> netdom trust ADATUM_NT4 /d:ADATUM /add↵
/UserD:ADATUM\administrator /PasswordD:*↵
/UserO:ADATUM_NT4\administrator /PasswordO:*
You can make the trust bidirectional (i.e., two-way) by adding a /TwoWay switch to the
example.
Discussion
It is common when migrating a single domain within a large, multidomain forest, as in
the case of a corporate merger or divestiture, to set up trusts to down-level master
account domains or resource domains, or to create a trust relationship with a single AD
domain in a remote, untrusted forest. This allows AD users to access resources in the
remote domain without providing alternate credentials. In the case of a remote Active
Directory forest, you might choose to establish an external trust in order to limit access
to and from only the specific domain that you specify, rather than allowing implicit
access between all domains on both sides of a transitive trust. In the GUI solution, each
side of the trust is completed independently to simulate a typical real-world situation
where a distinct administrative team manages each side of the trust.
See Also
“Understanding When to Create an External Trust” for details about external trusts;
“Understanding Trust Types” for a detailed explanation of the available trust types
36 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
62
|
2.15. Creating a Transitive Trust Between Two AD Forests
This recipe requires at least the Windows Server 2003 forest functional
level in both forests.
Problem
You want to create a transitive trust between two AD forests. This causes all domains
in both forests to trust each other without the need for additional trusts.
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. In the left pane, right-click the forest root domain and select Properties.
3. Click on the Trusts tab.
4. Click the New Trust button. Then click Next.
5. Enter the name of the domain and then click Next.
6. Select Forest Trust and then click Next.
7. Verify that a two-way trust direction is selected and then click Next.
8. Verify that “This domain only” is selected to create the trust and then click Next.
9. Verify that “Domain-wide authentication” is selected and then click Next.
10. Enter a complex password for the trust password and then click Next. Note that the
password must meet the domain password policy.
11. Review the trust settings summary and then click Next.
12. A message indicating that a trust relationship was created successfully will appear.
Click Next to configure the new trust.
13. Perform the same steps on the trusted domain. Then, on both sides, select Yes to
confirm the incoming trust and then click Next.
14. A success message will appear. Click Finish.
The trust should now appear in the Trusts tab of the domain properties.
2.15. Creating a Transitive Trust Between Two AD Forests | 37
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
63
|
Using a command-line interface
> netdom trust <Forest1DNSName> /Domain:<Forest2DNSName> /Twoway /Transitive↵
/ADD [/UserD:<Forest2AdminUser> /PasswordD:*]↵
[/UserO:<Forest1AdminUser> /PasswordO:*]
For example, to create a two-way forest trust from the AD forest adatum.com to the AD
forest othercorp.com, use the following command:
> netdom trust adatum.com /Domain:othercorp.com /Twoway /Transitive
/ADD /UserD:administrator@othercorp.com /PasswordD:*↵
/UserO:administrator@adatum.com /PasswordO:*↵
Discussion
A new type of trust called a forest trust was introduced in Windows Server 2003. With
a forest trust, you can define a single one-way or two-way transitive trust relationship
that extends to all the domains in both forests. You may want to implement a forest trust
if you merge with or acquire a company and you want all of the new company’s Active
Directory resources to be accessible for users in your Active Directory environment and
vice versa. Figure 2-4 shows a cross-forest trust scenario. To create a forest trust, you
need to use accounts from the Enterprise Admins group in each forest.
Figure 2-4. Forest trust
2.16. Creating a Shortcut Trust Between Two AD Domains
Problem
You want to create a shortcut trust between two AD domains that are in the same forest.
Shortcut trusts can make the authentication process more efficient between two do‐
mains in a forest.
38 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
64
|
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. In the left pane, right-click the forest root domain and select Properties.
3. Click on the Trusts tab.
4. Click the New Trust button. Then click Next.
5. Enter the name of the domain and then click Next.
6. Verify that a two-way trust direction is selected and then click Next.
7. Verify that “This domain only” is selected to create the trust and then click Next.
8. Verify that “Domain-wide authentication” is selected and then click Next.
9. Enter a complex password for the trust password and then click Next. Note that the
password must meet the domain password policy.
10. Review the trust settings summary and then click Next.
11. A message indicating that a trust relationship was created successfully will appear.
Click Next to configure the new trust.
12. Perform the same steps on the trusted domain. Then, on both sides, select Yes to
confirm the incoming trust and then click Next.
13. A success message will appear. Click Finish.
14. The trust should now appear in the Trusts tab of the domain properties.
Using a command-line interface
> netdom trust <Domain1DNSName> /Domain:<Domain2DNSName /Twoway /ADD↵
[/UserD:<Domain2AdminUser> /PasswordD:*]↵
[/UserO:<Domain1AdminUser> /PasswordO:*]
To create a shortcut trust from the emea.adatum.com domain to the apac.adatum.com
domain, use the following netdom command:
> netdom trust emea.adatum.com /Domain:apac.adatum.com /Twoway /ADD↵
/UserD:administrator@apac.adatum.com /PasswordD:*↵
/UserO:administrator@emea.adatum.com /PasswordO:*
2.16. Creating a Shortcut Trust Between Two AD Domains | 39
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
65
|
Discussion
Consider the forest shown in Figure 2-5. It has five domains in a single domain tree.
For authentication requests for Domain 3 to be processed by Domain 5, the request
must traverse the path from Domain 3 to Domain 2 to Domain 1 to Domain 4 to Domain
5. If you create a shortcut trust between Domain 3 and Domain 5, the authentication
path is just a single hop from Domain 3 to Domain 5. To create a shortcut trust, you
must be a member of the Domain Admins group in both domains, or a member of the
Enterprise Admins group.
Figure 2-5. Shortcut trust
2.17. Creating a Trust to a Kerberos Realm
Problem
You want to create a trust to a Kerberos realm.
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. In the left pane, right-click the forest root domain and select Properties.
3. Click on the Trusts tab.
4. Click the New Trust button. Click Next.
5. Enter the name of the realm and then click Next.
6. Verify that “Realm trust” is selected and then click Next.
7. Select Transitive for the trust transitivity and then click Next.
40 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
66
|
8. Verify that a two-way trust is selected for the direction of the trust and then click
Next.
9. Enter a complex password for the trust password; click Next. Note that the password
must meet the domain password policy.
10. Review the trust settings summary and then click Next.
11. A success message will appear. Click Finish.
12. The trust should now appear in the Trusts tab of the domain properties.
Using a command-line interface
> netdom trust <ADDomainDNSName> /Domain:<KerberosRealmDNSName>↵
/Realm /ADD /PasswordT:<TrustPassword>↵
[/UserO:<ADDomainAdminUser> /PasswordO:*]
The <TrustPassword> has to match what was set on the Kerberos side. To create a realm
trust from the adatum.com domain to the Kerberos realm called kerb.adatum.com, use
the following command:
> netdom trust adatum.com /Domain:kerb.adatum.com↵
/Realm /ADD /PasswordT:MyKerbRealmPassword↵
/UserO:administrator@adatum.com /PasswordO:*
Discussion
You can create a Kerberos realm trust between an Active Directory domain and a nonWindows Kerberos v5 realm. A realm trust can be used to allow clients from the nonWindows Kerberos realm to access resources in Active Directory, and vice versa. See
Recipe 15.4 for more information on MIT Kerberos interoperability with Active
Directory.
See Also
“Understanding When to Create a Realm Trust” for information about realm trusts;
“Understanding Trust Types” for a detailed explanation of the available trust types
2.18. Viewing the Trusts for a Domain
Problem
You want to view the trusts that have been configured for a domain.
2.18. Viewing the Trusts for a Domain | 41
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
67
|
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. In the left pane, right-click the domain you want to view and select Properties.
3. Click on the Trusts tab.
Using a command-line interface
To enumerate domain trusts using the netdom utility, use the following syntax:
> netdom query trust /Domain:<DomainDNSName>
You can also use nltest, available from the Windows Support Tools, as follows:
> nltest /domain_trusts /All_Trusts
Using PowerShell
Get-ADTrust -filter *
If the adatum.com domain is configured with a two-way external trust with the barce‐
lona.corp domain, running this script from dc1.adatum.com would produce the fol‐
lowing output:
Direction : BiDirectional
DisallowTransivity : False
DistinguishedName : CN=barcelona.corp,CN=System,dc=adatum,dc=com
ForestTransitive : True
IntraForest : False
IsTreeParent : False
IsTreeRoot : False
Name : barcelona.corp
ObjectClass : trustedDomain
ObjectGUID : 98616652-c2ec-4057-a7ea-f639e1ec2680
SelectiveAuthentication : False
SIDFilteringForestAware : False
SIDFilteringQuarantined : False
Source : dc=adatum,dc=com
Target : barcelona.corp
TGTDelegation : False
TrustAttributes : 8
TrustedPolicy :
TrustingPolicy :
TrustType : Uplevel
UplevelOnly : False
UsesAESKeys : False
UsesRC4Encryption : False
42 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
68
|
Discussion
Using a graphical user interface
You can view the properties of a particular trust by clicking on a trust and clicking the
Properties button.
Using a command-line interface
You can include the /Direct switch with netdom if you want to view only direct-trust
relationships. If you don’t use /Direct, implicit trusts that occur due to transitive trust
relationships will also be listed.
The nltest command can take the following additional switches to modify the default
behavior of the /domain_trusts switch:
/Primary
Returns only the domain that the computer account you’re running nltest from
belongs to
/Forest
Returns domains that are in the same forest as the primary domain
/Direct_Out
Returns only those domains that are trusted by the primary domain
/Direct_In
Returns only those domains that trust the primary domain
/v
Displays domain SIDs and GUIDs
See Also
“Understanding Trusts” for a deep dive into Active Directory trusts
2.19. Verifying a Trust
Problem
You want to verify that a trust is working correctly. This is the first diagnostic step to
take if users notify you that authentication to a remote domain appears to be failing.
2.19. Verifying a Trust | 43
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
69
|
Solution
Using a graphical user interface
For the Windows Server 2003, Windows Server 2008, and Windows Server 2012 ver‐
sions of the Active Directory Domains and Trusts snap-in:
1. In the left pane, right-click on the trusting domain and select Properties.
2. Click the Trusts tab.
3. Click the domain that is associated with the trust you want to verify.
4. Click the Properties button.
5. Click the Validate button and select the option to validate the incoming trust or
validate only the outgoing trust.
Using a command-line interface
> netdom trust <TrustingDomain> /Domain:<TrustedDomain> /Verify /verbose↵
[/UserO:<TrustingDomainUser> /PasswordO:*]↵
[/UserD:<TrustedDomainUser> /PasswordD:*]
Discussion
Verifying a trust consists of checking connectivity between the domains and determin‐
ing if the shared secrets of a trust are synchronized between the two domains. It is
recommended that you validate both sides of the trust. You can validate both sides of
the trust by selecting the option to validate the incoming trust during the verification.
Otherwise, you have to perform verification from each side independently.
Using a graphical user interface
The Active Directory Domains and Trusts screens have not changed between Windows
2003 and Windows Server 2012.
Using a command-line interface
If you want to verify a Kerberos trust, use the /Kerberos switch with the netdom
command.
See Also
“Understanding Trusts” for a deep dive into Active Directory trusts
44 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
70
|
2.20. Resetting a Trust
Problem
You want to reset a trust password. If you’ve determined a trust is broken, you need to
reset it, which will allow users to authenticate across it again.
Solution
Using a graphical user interface
Follow the same directions as in Recipe 2.19. The option to reset the trust will be pre‐
sented only if the verification/validation did not succeed. In Windows Server 2012, if
the trust validation process fails, you will be prompted to reset the trust passwords.
Using a command-line interface
> netdom trust <TrustingDomain> /Domain:<TrustedDomain> /Reset /verbose↵
[/UserO:<TrustingDomainUser> /PasswordO:*]↵
[/UserD:<TrustedDomainUser> /PasswordD:*]
Discussion
Resetting a trust synchronizes the shared secrets (i.e., passwords) for the trust. The PDC
Emulators in both domains are used to synchronize the password, so they must be
reachable during the reset process.
Using a command-line interface
If you are resetting a Kerberos realm trust, you’ll need to specify the /PasswordT option
with netdom.
See Also
Recipe 2.19 for verifying a trust
2.21. Removing a Trust
Problem
You want to remove a trust. This is commonly done when the remote domain has been
decommissioned or access to it is no longer required.
2.20. Resetting a Trust | 45
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
71
|
Solution
Using a graphical user interface
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. In the left pane, right-click on the trusting domain and select Properties.
3. Click the Trusts tab.
4. Click on the domain that is associated with the trust you want to remove.
5. Click the Remove button.
6. Select the option to remove the trust from both domains, or the option to delete
the trust only from the local domain, and then click OK.
Using a command-line interface
To remove a trust relationship using the netdom utility, use the following syntax:
> netdom trust <TrustingDomain> /Domain:<TrustedDomain> /Remove /verbose↵
[/UserO:<TrustingDomainUser> /PasswordO:*]↵
[/UserD:<TrustedDomainUser> /PasswordD:*]
To remove a trust using a combination of AdFind and AdMod, issue the following two
commands:
> adfind -b cn=<Trusted Domain>,cn=system,<Domain DN> -dsq | admod -rm
> adfind -b cn=<TrustName>$,cn=users,<Domain DN> -dsq | admod -rm
Both of these commands first use AdFind to return the object that needs
to be deleted, and then use the | operator to send that object to AdMod
to perform the actual deletion.
Discussion
Trusts are stored in Active Directory as two objects: a trustedDomain object in the
System container and a user object in the Users container. Both of these objects need
to be removed when deleting a trust. The GUI and netdom solutions take care of that in
one step, but in the AdMod example, both objects needed to be explicitly deleted.
46 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
72
|
2.22. Enabling SID Filtering for a Trust
Problem
You want to enable Security Identifier (SID) filtering for a trust. By enabling SID filter‐
ing, you can keep a hacker from spoofing an SID across a trust.
Solution
Using a command-line interface
> netdom trust <TrustingDomain> /Domain:<TrustedDomain> /EnableSIDHistory:No↵
[/UserO:<TrustingDomainUser> /PasswordO:*]↵
[/UserD:<TrustedDomainUser> /PasswordD:*]
Using PowerShell to view SID filtering settings
The following PowerShell command retrieves the current SID filtering settings on a
trust configured with the remote treyresearch.net domain:
Get-ADTrust treyresearch.net | FL *SID*
Discussion
A security vulnerability exists with the use of SID history, which is described in detail
in MS KB 289243. An administrator in a trusted domain can modify the SID history
for a user, which could grant her elevated privileges in the trusting domain. The risk of
this exploit is relatively low due to the complexity of forging an SID, but nevertheless,
you should be aware of it. To prevent this from happening you can enable SID filtering
for a trust. When SID filtering is enabled, the only SIDs that are used as part of a user’s
token are from those domains in the trust path of the trusted domain—so if the trusted
domain is adatum.com, which has a child domain called emea.adatum.com, SID filter‐
ing would accept SIDs from both the adatum.com domain and its child domain,
emea. SIDs that are not a part of the trusted domain’s trust path are not included, so an
SID from the barcelona.corp would be stripped from the user’s access token. SID filtering
makes things more secure, but it prevents the use of SID history and can cause problems
with transitive trusts and domain migrations. For example, if we migrated a user from
barcelona.corp to adatum.com, that user’s barcelona.corp SID history entry would be
ignored as long as SID filtering was in place. You would need to update the access control
lists (ACLs) on resources in barcelona.corp to point to the migrated user’s ada‐
tum.com SID, which would allow the user to access them with SID filtering in place.
SID filtering is enabled by default on all trust relationships created in Windows 2000
Service Pack 4 and later. This can cause unexpected behavior if you create a trust rela‐
tionship under an earlier Service Pack version, but then delete and re-create the trust
2.22. Enabling SID Filtering for a Trust | 47
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
73
|
under SP4 or later. You can disable SID filtering by running the netdom command with
the /EnableSIDHistory:Yes switch.
See Also
MS KB 289243 (MS02-001: Forged SID Could Result in Elevated Privileges in Windows
2000)
2.23. Enabling Quarantine for a Trust
Problem
You want to enable Quarantine for a trust. By enabling Quarantine, you can greatly
restrict the acceptable domain SIDs in a trust relationship.
Solution
Using a command-line interface
> netdom trust <TrustingDomain> /Domain:<TrustedDomain> /Quarantine:Yes↵
[/UserO:<TrustingDomainUser> /PasswordO:*]↵
[/UserD:<TrustedDomainUser> /PasswordD:*]
Discussion
A security vulnerability exists with the use of SID history, which is described in detail
in MS KB 289243. An administrator in a trusted domain can modify the SID history
for a user, which could grant him elevated privileges in the trusting domain. The risk
of this exploit is relatively low due to the complexity in forging an SID, but nevertheless,
you should be aware of it. You can put in strong restrictions in order to minimize the
risk of privilege elevation by enabling Quarantine for a trust. When Quarantine is en‐
abled, the only SIDs that are used as part of a user’s token are from those domains in
the trusted domain itself. So if the trusted domain is adatum.com, which has a child
domain called emea.adatum.com, Quarantine will only accept SIDs from adatum.com
itself. Even domain SIDs that are a part of the trusted domain’s trust path are not in‐
cluded, so an SID from emea.adatum.com would be stripped from the user’s access
token. Enabling Quarantine for a trust effectively removes the transitivity of a forest
trust relationship, restricting the trust relationship to only the domain that you specified
when you created the trust. (This causes a forest trust to emulate the default behavior
of an external trust instead.)
You can disable Quarantine on a trust relationship by running the netdom command
again and specifying the /Quarantine:No switch.
48 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
74
|
2.24. Managing Selective Authentication for a Trust
Problem
You want to enable or disable Selective Authentication for a trust. By enabling Selective
Authentication, you can control which computers—in a trusting domain—users in a
trusted domain can access. Disabling Selective Authentication will allow users in the
trusted domain to authenticate to any computer in the trusting domain.
Solution
Using a graphical user interface
To enable Selective Authentication:
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. To enable Selective Authentication for a forest trust, right-click on the forest root
domain and select Properties. To enable Selective Authentication for an external
trust, right-click on the domain you wish to configure and select Properties.
3. On the Trusts tab, right-click on the trust that you wish to administer and select
Properties.
4. On the Authentication tab, click Selective Authentication.
5. Click OK to finish.
To disable Selective Authentication:
1. Open the Active Directory Domains and Trusts snap-in (domain.msc).
2. To enable forest-wide authentication for a forest trust, right-click on the forest root
domain and select Properties. To enable domain-wide authentication for an exter‐
nal trust, right-click on the domain you wish to configure and select Properties.
3. On the Trusts tab, right-click on the trust that you wish to administer and select
Properties.
4. In the case of a forest trust, on the Authentication tab click Forest-Wide Authen‐
tication. For an external trust, on the Authentication tab click Domain-Wide
Authentication.
5. Click OK to finish.
2.24. Managing Selective Authentication for a Trust | 49
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
75
|
To grant permissions on individual computers in the trusting domain:
1. Open the Active Directory Users and Computers snap-in (dsa.msc).
2. Right-click on the computer object on which you wish to grant permissions and
select Properties.
3. On the Security tab, select the user or group that you want to authorize, and select
the Allow checkbox next to the Allowed to Authenticate permission.
4. Click OK to finish.
Using a command-line interface
To enable Selective Authentication, use the following syntax:
> netdom trust <TrustingDomain> /Domain:<TrustedDomain> /SelectiveAUTH:Yes↵
[/UserO:<TrustingDomainUser> /PasswordO:*]↵
[/UserD:<TrustedDomainUser> /PasswordD:*]
Use the /SelectiveAUTH:No switch to enable domain- or forest-wide
authentication.
Discussion
Trust relationships since Windows Server 2003, by default, allow users in a trusted
domain to authenticate to and access shared resources on any computer in the trusting
domain. Selective Authentication, also known as the Authentication Firewall, will re‐
strict access to only those computers in the trusted domain that you specifically desig‐
nate. This level of increased security is particularly useful when you need to grant access
to shared resources in your forest, but you need to restrict that access to only a limited
set of users in the remote forest.
For users in a trusted domain or forest to be able to access resources in a trusting domain
or forest, where the trust authentication setting has been set to Selective Authentication,
each user must be explicitly granted the Allowed to Authenticate permission on the
security descriptor of the computer objects (resource computers) that reside in the
trusting domain or forest. By default, only members of the Account Operators, Admin‐
istrators, Domain Admins, Enterprise Admins, and SYSTEM groups in the trusting do‐
main have the ability to modify this permission.
Enabling Selective Authentication has the potential to create a huge
increase in your AD administrative overhead, and should only be en‐
abled when the security risks justify the administrative implications.
50 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
76
|
2.25. Finding Duplicate SIDs in a Domain
Problem
You want to find any duplicate SIDs in a domain. Generally, duplicate SIDs in a domain
should not exist, but it is possible in some situations, such as when the relative identifier
(RID) FSMO role owner has to be seized.
Solution
Using a command-line interface
To find duplicate SIDs, run the following command, replacing <DomainController
Name> with a domain controller or domain name:
> ntdsutil "sec acc man" "co to se <DomainControllerName" "check dup sid" q q
The following message will be returned:
Duplicate SID check completed successfully. Check dupsid.log for any duplicates
The dupsid.log file will be in the directory where you started ntdsutil.
If you want to delete any objects that have duplicate SIDs, you can use the following
command:
> ntdsutil "sec acc man" "co to se <DomainControllerName>" "clean dup sid" q q
Like the check command, the clean command will generate a message like the following
upon completion:
Duplicate SID cleanup completed successfully. Check dupsid.log for any duplicates
Discussion
All security principals in Active Directory have an SID, which is used to uniquely iden‐
tify the object in the Windows security system. There are two parts of an SID: the domain
identifier and the RID. Domain controllers are allocated a RID pool from the RID FSMO
for the domain. When a new security principal (user, group, or computer) is created,
the domain controller takes an RID from its pool to generate an SID for the account.
In some rare circumstances, such as when the RID master role is seized, overlapping
RID pools can be allocated, which can ultimately lead to duplicate SIDs. Having dupli‐
cate SIDs is a potentially hazardous problem because a user, group, or computer could
gain access to sensitive data it was never intended to have access to.
2.25. Finding Duplicate SIDs in a Domain | 51
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
77
|
See Also
MS KB 816099 (How to Find and Clean Up Duplicate Security Identifiers with Ntdsutil
in Windows Server 2003)
2.26. Adding Additional Fields to Active Directory Users
and Computers
Problem
You want to add to the list of attributes by which you can search and sort records within
the ADUC (Active Directory Users and Computers) MMC snap-in (dsa.msc).
Solution
Using a graphical user interface
In this example, we will add the operating system service-pack-level attributes of com‐
puter objects to ADUC to allow you to search and sort by these fields:
1. Open ADSI Edit.
2. If an entry for the Configuration NC is not already displayed, do the following:
a. Right-click on ADSI Edit in the right pane and click “Connect to.”
b. Under “Select a well-known naming context,” select Configuration. Click Ad‐
vanced if you need to specify alternate credentials, and then click OK to create
the connection.
c. In the left pane, click on cn=DisplaySpecifiers and then cn=409. Right-click
on the container and select Properties.
If you are using a locale other than one that uses US English, specify
the appropriate locale number in place of cn=409, using the refer‐
ence listed by Microsoft.
3. Right-click on cn=computerDisplay and select Properties.
4. Double-click on attributeDisplayNames. Type operatingSystemServicePack,
Operating System Service Pack, and click Add.
5. Click Apply, followed by OK.
52 | Chapter 2: Forests, Domains, and Trusts
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
78
|
Using a command-line interface
First create an LDIF file containing the following information and save it as modi
fy_display_specifiers.ldif:
dn: cn=computer-display,cn=409,cn=DisplaySpecifiers,
cn=Configuration, <ForestRootDN>
changetype: modify
add: attributeDisplayNames
attributeDisplayNames: operatingSystemServicePack,Operating System Service Pack
-
Then run the following command:
> ldifde -v -i -f modify_display_specifiers.ldf
You can also modify this information using a combination of AdFind and AdMod, as
follows:
> adfind -config -rb cn=computer-display,cn=409,cn=DisplaySpecifiers |↵
admod "attributeDisplayNames:+:operatingSystemServicePack,Operating System↵
Service Pack"
Discussion
When working within the Active Directory Users and Computers MMC snap-in, there
are a number of default attributes for each type of object that you can use to either search
or sort on. Computer objects, for example, allow you to search and sort by the computer
name, description, manager, operating system, and pre-Windows 2000 computer name.
Once you add a new attribute to the display specifiers, you can access it by opening
ADUC, right-clicking on a container, and clicking on Find. Select Computers in the
drop-down box next to Find, and click on Advanced. When you click on Field, you’ll
see the new field that you just added; you can now use it to search for objects within the
ADUC snap-in.
See Also
Recipe 4.14 for more on modifying an object; MSDN: Attribute-Display-Names [AD
Schema]; MSDN: PutEx Method [ADSI]
2.26. Adding Additional Fields to Active Directory Users and Computers | 53
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
79
| null |
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
80
|
CHAPTER 3
Domain Controllers, Global Catalogs,
and FSMOs
3.0. Introduction
Domain controllers are servers that host an Active Directory domain and provide au‐
thentication and directory services to clients. A domain controller (DC) can only be
authoritative (i.e., it can only process authentication requests) for a single domain, but
it can store partial read-only copies of objects in other domains in the forest if it is
enabled as a global catalog server. All domain controllers in a forest also host a copy of
the Configuration and Schema naming contexts (NCs), which are replicated to all do‐
main controllers in a forest.
Active Directory domain controllers are fully multimaster in nature, meaning that up‐
dates to the directory (with a few exceptions, which we’ll discuss next) can originate on
any domain controller in a forest. However, some tasks are sufficiently sensitive in nature
that they cannot be distributed to all DCs, due to the potential of significant issues arising
from more than one DC performing the same update simultaneously. For example, if
two different domain controllers made conflicting updates to the schema, the impact
could be severe and could result in data loss or an unusable directory. For this reason,
Active Directory uses Flexible Single Master Operation (FSMO, pronounced “fiz-mo”)
roles. For each FSMO role, only one domain controller acts as the role owner and per‐
forms the tasks associated with the role. These roles are termed “single master” because
only a single DC can hold a FSMO role at any one time, but they are “flexible” because
a single physical server can host multiple FSMOs, and a FSMO role can be transferred
from one DC to another, largely without repercussion. In each Active Directory forest
there are two FSMO roles that are unique across an entire forest and three FSMO roles
that appear within each domain. So, in the case of a forest containing three domains,
there would be two forest-wide FSMO role holders and nine domain-wide FSMO role
55
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
81
|
holders, three for each of the three domains. See Recipe 3.29 for more information on
FSMO roles.
In Windows Server 2008, Microsoft introduced the Read-Only Domain Controller, or
RODC, to improve security for organizations that need to deploy DCs in branch offices
or other remote locations where the physical or logical security of the DC might not be
completely assured. An RODC will receive replication updates from writable DCs in
the same domain, but domain controllers will not replicate from an RODC. See
Recipe 3.2 for more information on RODCs.
The Anatomy of a Domain Controller
Each domain controller is represented in Active Directory by several objects; the two
main ones are a computer object and an nTDSDSA object. The computer object is neces‐
sary because a domain controller needs to be represented as a security principal just like
any other type of computer in Active Directory. The default location in a domain for
domain controller computer objects is the Domain Controllers organizational unit
(OU) at the root of the domain. They can be moved to a different OU, but it is highly
recommended that you don’t move them. One of the reasons not to move them is be‐
cause any DCs that you move outside the domain controller’s OU will not receive the
same Group Policy Object settings as those within the OU, which can lead to unpre‐
dictable behavior on your network. Table 3-1 contains some useful attributes of domain
controller computer objects.
Table 3-1. Attributes of domain controller computer objects
Attribute Description
dnsHostName Fully qualified DNS name of the DC.
msDS-AdditionalDnsHostName Contains the old DNS name of a renamed DC.
msDS-AdditionalSamAccountName Contains the old NetBIOS name of a renamed DC.
operatingSystem Text description of the operating system running on the DC.
operatingSystemServicePack Service pack version installed on the DC.
operatingSystemVersion Numeric version of the operating system installed on the DC.
sAMAccountName NetBIOS-style name of the DC.
serverReferenceBL DN of the DC’s server object contained under the Sites
container in the Configuration NC.
servicePrincipalName List of SPNs supported by the DC.
56 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
82
|
Domain controllers are also represented by several objects under the Sites container
in the Configuration NC. The Sites container stores objects that are needed to create
a site topology, including site, subnet, sitelink, and server objects. The site topology
is necessary so that domain controllers can replicate data efficiently around the network
as well as localize authentication traffic. See Chapter 11 for more information on sites
and replication.
Each domain controller has an nTDSDSA object that is subordinate to the domain con‐
troller’s server object in the site it is a member of. For example, if the DC1 domain
controller were part of the RTP site, its nTDSDSA object would be located here:
cn=NTDS Settings,cn=DC1,cn=RTP,cn=sites,cn=configuration,dc=adatum,dc=com
Table 3-2 lists some of the interesting attributes that are stored with nTDSDSA objects.
Table 3-2. Attributes of domain controller nTDSDSA objects
Attribute Description
hasMasterNCs List of DNs for the naming contexts the DC is authoritative for. This
does not include application partitions.
hasPartialReplicaNCs List of DNs for the naming contexts the DC has a partial read-only
copy of.
msDS-HasDomainNCs The DN of the domain the DC is authoritative for.
msDS-HasMasterNCs List of DNs for the naming contexts (domain, configuration, and
schema) and application partitions the DC is authoritative for.
options If the low-order bit of this attribute is set, the domain controller stores
a copy of the global catalog.
invocationID GUID that is assigned to the Active Directory database itself when
the first domain controller is initially installed. When the first DC is
initially installed, the invocationID value is the same as the
objectGUID for the DC itself; however, the invocationID
changes whenever a restore operation is performed or when the DC
is configured to host an application partition.
RODCs also maintain a number of RODC-specific attributes, primarily relating to the
Password Replication Policy (PRP) that is configured for each RODC in an Active Di‐
rectory forest. As discussed previously, writable DCs will store an entire copy of the
Domain NC on the hard drive of each DC, which creates a significant liability if the
physical or logical security of one of these DCs is compromised. By contrast, an RODC
will store most information from the Domain NC, but by default will not store passwords
and other security secrets for any Active Directory user account. (A default RODC will
contain only secrets for the local Administrator and the local krbtgt accounts, both of
which are required for the RODC to function.) An Active Directory administrator can
configure a Password Replication Policy for a single RODC or for all RODCs in a domain
that will specify the following:
3.0. Introduction | 57
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
83
|
• Users and computers whose password secrets are permitted to be cached on indi‐
vidual RODCs or on all RODCs in a domain
• Users and computers whose password secrets are never permitted to be cached on
individual RODCs, or on all RODCs in a domain
In order to maintain this information, each RODC contains a number of attributes
relating to the Password Replication Policy. Each RODC will also maintain information
pertaining to which user and computer accounts’ password secrets have actually been
cached by a particular RODC, instead of merely being permitted to do so.
Table 3-3 lists some of the interesting attributes pertaining to Password Replication
Policy that are stored within an RODC’s computer object.
Table 3-3. Interesting attributes of a Read-Only Domain Controller
Attribute Description
msDS-Reveal-OnDemandGroup Accounts that are allowed to be cached on the RODC.
msDS-NeverRevealGroup Accounts that are not allowed to be cached on the RODC.
msDS-AuthenticatedAtDC A forward link indicating a list of RODCs through which a user has
successfully authenticated to a full DC.
msDS-AuthenticatedToAccountList A backlink indicating a list of accounts that have successfully
authenticated to a full DC through the RODC.
3.1. Promoting a Server to a Domain Controller
Problem
You want to promote a server to a domain controller. You may need to promote a server
to a domain controller to initially create a domain in an Active Directory forest, or to
add additional domain controllers to a domain for load balancing and fault tolerance.
Solution
The following process will promote a server as an additional domain controller in an
existing domain. On a Windows Server 2012 computer:
1. Add the Active Directory Domain Services role. After the role installation, a noti‐
fication will appear within Server Manager.
2. Click Notifications and then click “Promote this server to a domain controller.”
3. Select the “Add a domain controller to an existing domain” option. Specify the
desired domain and credentials (or accept the default values if appropriate) and
then click Next.
58 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
84
|
4. Select the desired domain controller options: “Domain Name System (DNS)
server,” “Global Catalog (GC),” and/or “Read only domain controller (RODC).”
5. Type a Directory Services Restore Mode (DSRM) password and then click Next.
6. Select the desired additional options: install from media—if installing from media
—and replication from a specific domain controller. Then click Next.
7. Specify the desired database, logfiles, and SYSVOL paths and then click Next.
8. Review all of the options and then click Next.
9. After a successful prerequisite check, click Install to complete the promotion. Note
that the server will automatically reboot after completing the promotion process.
Discussion
Promoting a server to a domain controller is the process where the server becomes
authoritative for an Active Directory domain. When you initiate the promotion, a wiz‐
ard interface walks you through a series of screens that collect information about the
forest and domain into which to promote the server. There are several options for pro‐
moting a server to domain controller status:
• Promoting into a new forest (see Recipe 2.1)
• Promoting into a new domain tree or child domain (see Recipe 2.3)
• Promoting into an existing domain
A server can also be promoted by using PowerShell. See the following section for links
to some recipes with PowerShell steps for domain controller promotion.
See Also
Recipe 2.1 for creating a new forest; Recipe 2.3 for creating a new domain; Recipe 3.2;
Recipe 3.7
3.2. Promoting a Server to a Read-Only Domain Controller
Problem
You want to promote a server to an RODC in a Windows Server 2012 domain.
This recipe requires that at least one writable Windows Server 2008 or
newer domain controller is present in the domain.
3.2. Promoting a Server to a Read-Only Domain Controller | 59
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
85
|
Solution
1. First, add the Active Directory Domain Services role using Server Manager.
2. Click “Promote this server to a domain controller” in the notification area.
3. Verify that the “Add a domain controller to an existing domain” option is selected.
4. Type the domain name and domain credentials and then click Next.
5. Select the “Read only domain controller (RODC)” option, enter the Directory
Services Restore Mode (DSRM) password, and then click Next.
6. Select a user account for delegation. Verify the accounts that are allowed to replicate
passwords and the accounts that are denied from replicating passwords. Click Next.
7. Select a domain controller to replicate from and then click Next.
8. Verify the AD DS database locations and then click Next.
9. Review the summary and then click Next.
10. After the prerequisites have been verified, click Install to begin the promotion.
The server will automatically restart after replication is complete.
Discussion
In order to add a Read-Only Domain Controller to an Active Directory domain, the
domain must be running at the Windows Server 2003 or later domain functional mode,
and at least one writable Windows Server 2008 or later domain controller must be
available, since an RODC will only accept replication traffic from a 2008 or later writable
DC.
To further customize the behavior of an RODC installation, you can select the Advanced
installation option, which will allow you to install an RODC using IFM media, as well
as customizing the Password Replication Policy. You can also automate RODC instal‐
lation by using an unattend.txt file as described in a later recipe.
You can also use the Install-ADDSDomainController PowerShell cmdlet to promote
a server as an RODC.
See Also
Recipe 3.3; Recipe 3.4; Recipe 3.5; Recipe 3.7
60 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
86
|
3.3. Performing a Two-Stage RODC Installation
Problem
You want to perform a two-stage promotion of a server to an RODC in a Windows
Server 2012 domain.
This recipe requires that at least one writable Windows Server 2008 or
later domain controller is present in the domain.
Solution
The first stage of the two-stage installation process is performed from a writable Win‐
dows Server 2012 domain controller, using the following steps.
The server designated for configuration as an RODC must be joined to
a workgroup prior to the start of this process; if the computer is joined
to the domain as a member server, these steps will fail. The server must
also be configured with the same name that you will specify in the fol‐
lowing steps.
1. From Active Directory Users and Computers, right-click the Domain Control
lers OU and then click “Pre-create Read only Domain Controller account.”
2. When the Active Directory Domain Services Installation Wizard appears, click
Next to begin.
3. Specify the account credentials or accept the default settings by using the currently
logged on user credentials, and then click Next.
4. Enter the desired computer name of the RODC and then click Next.
5. Select the site location for the RODC and then click Next.
6. Select the additional options for DNS server and global catalog services and then
click Next.
7. Add the user or group that will have local administrative rights to the RODC and
then click Next.
8. Review the selections on the summary screen and then click Next.
9. After the successful installation of the RODC, click Finish to close the wizard.
3.3. Performing a Two-Stage RODC Installation | 61
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
87
|
The second stage of the RODC installation will be completed from the console of the
server that is to be configured as an RODC, using the following steps:
1. Click “Promote this server to a domain controller” in the Server Manager notifi‐
cation area and then click Next.
2. Enter the parent domain name and credentials and click Next.
3. Verify that the “Use existing RODC account” option is selected. Enter a password
for DSRM and then click Next.
4. Specify a DC to replicate from and then click Next.
5. Specify the locations for the database, logfiles, and SYSVOL, and then click Next.
6. Review the options and then click Next.
7. After the prerequisites have been successfully checked, click Install to begin
promotion.
8. The server will automatically reboot after completion.
Discussion
When deploying RODCs to remote locations, you have the ability to perform a twostage installation in which you pre-create the RODC’s domain controller account. Once
this first stage is completed, an on-site administrator can complete the installation
without requiring elevated rights within Active Directory. This Admin Role Separa‐
tion feature allows you to configure one or more users or groups as local administrators
of an individual RODC, without granting administrative privileges within the Active
Directory domain itself.
When pre-creating the RODC computer account, you can select the Advanced instal‐
lation option to customize the Password Replication Policy for the RODC prior to
deployment.
See Also
Recipe 3.4; Chapters 6 and 7 for more on managing users and groups
3.4. Modifying the Password Replication Policy
Problem
You wish to modify the Password Replication Policy on a Read-Only Domain Controller
to control which user and computer passwords can and cannot be cached on a particular
RODC.
62 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
88
|
Solution
Using a graphical user interface
1. Open Active Directory Users and Computers and then select the built-in Domain
Controllers OU.
2. Locate the desired RODC, right-click it, and then click Properties.
3. Select the Password Replication Policy tab.
4. Click Add. Then click the “Allow passwords for the account to replicate to this
RODC” option. Click OK.
5. Enter the user or group that you will cache passwords on the RODC and then click
OK.
6. Click OK to complete the process.
Using a command-line interface
To add a user or group to the “Allowed to Cache” list, use the following syntax:
repadmin /prp add <DomainControllerName> allow "<GroupName>"
To remove a user or group from the “Allowed to Cache” list, use the following syntax:
repadmin /prp delete <DomainControllerName> allow "<GroupName>"
To add a user or group to the “Denied to Cache” list, use the following syntax:
repadmin /prp add <DomainControllerName> deny "<GroupName>"
Discussion
A separate Password Replication Policy can be maintained individually on each ReadOnly Domain Controller; this is implemented by the addition of several attributes on
each RODC that control which users’ passwords can and cannot be cached on the RODC
in question. It is good practice to manage these attributes using security groups rather
than individual users or computers, as this makes for a much more simplified manage‐
ment model. By default, the following domain groups are added to the Password Rep‐
lication Policy of each RODC in the domain:
• msDS-NeverRevealGroup
— Account operators
— Administrators
— Backup operators
— Denied RODC Password Replication Group
3.4. Modifying the Password Replication Policy | 63
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
89
|
— Server operators
• msDS-RevealOnDemandGroup
— Allowed RODC Password Replication Group
When Windows evaluates the Password Replication Policy, a “Deny” setting would
override an “Allow” setting; for example, if a user is a member of two security groups
that are configured with contradictory settings. As with most aspects of Windows se‐
curity, the “Keep It Simple” principle should be followed whenever possible.
Using a command-line interface
You can modify the password caching policy on all RODCs in a single command by
using an asterisk (*) in place of the RODC hostname. The asterisk is a wildcard character
that represents any hostname. It can be combined with characters before or after. An
example is using DC* to represent all RODCs that have a hostname starting with “DC.”
See Also
TechNet article on the repadmin command; Chapter 4 for more on searching and up‐
dating Active Directory; Chapters 6 and 7 for more on managing users and groups
3.5. Promoting a Server to a Windows Server 2012
Domain Controller from Media
This recipe requires that the server being promoted is running Win‐
dows Server 2012.
Problem
You want to promote a server to be a new domain controller using a backup from another
domain controller as the initial source of the Active Directory database instead of rep‐
licating the entire NTDS.DIT file and SYSVOL over the network.
Solution
From a DC, run the ntdsutil program.
1. From ntdsutil, run the following commands:
a. activate instance ntds
b. ifm
64 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
90
|
c. create sysvol full <PathToSaveData>
2. Copy the media from the saved located to the new server that will be promoted.
3. Add the Active Directory Domain Services role. After the role installation, a noti‐
fication will appear within Server Manager.
4. Click Notifications and then click “Promote this server to a domain controller.”
5. Select the “Add a domain controller to an existing domain” option. Specify the
desired domain and credentials (or accept the default values if appropriate) and
then click Next.
6. Select the desired domain controller options: “Domain Name System (DNS)
server,” “Global Catalog (GC),” and/or “Read only domain controller (RODC).”
Note that a full backup is not necessary if you are planning to promote a server to
an RODC (instead, you would use create sysvol RODC rather than create sysvol
full).
7. Type a Directory Services Restore Mode (DSRM) password and then click Next.
8. Select the desired additional options, including the Install from Media option. Type
the path to the IFM files and then specify the replication from a specific domain
controller if desired. Then click Next.
9. Specify the desired database, logfiles, and SYSVOL paths and then click Next.
10. Review all of the options and then click Next.
11. After a successful prerequisite check, click Install to complete the promotion. Note
that the server will automatically reboot after completing the promotion process.
Discussion
The ability to promote a domain controller using the System State backup of another
domain controller was first introduced in Windows Server 2003. Without the Install
from Media option, a new domain controller has to replicate the entire NTDS.DIT
Active Directory database file and SYSVOL folder over a network connection, object by
object, from an existing domain controller. For organizations with a sizeable Active
Directory DIT file and/or very poor network connectivity to a remote site, replicating
the full contents over the network presented challenges. Under these conditions, the
promotion process could take a prohibitively long time to complete. With the Install
from Media option, the initial domain controller promotion process can be substantially
quicker. After you’ve done the initial installation from media, the new domain controller
will replicate any changes that have been made to the Active Directory database since
the backup media was created.
3.5. Promoting a Server to a Windows Server 2012 Domain Controller from Media | 65
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
91
|
Be sure that the age of the backup files you are using is significantly less
than your AD forest’s tombstone lifetime. If you install a domain con‐
troller using backup files that are older than the tombstone lifetime
value, you could run into issues with deleted objects being reinjected
into the Active Directory database after their tombstone lifetime has
expired.
See Also
Chapter 16 for more on backing up Active Directory; Recipe 16.24 for modifying the
tombstone lifetime of a domain; MS KB 216993 (Useful Shelf Life of a System-State
Backup of Active Directory)
3.6. Demoting a Domain Controller
Problem
You want to demote a Windows Server 2012 domain controller from a domain.
Solution
Using a graphical user interface
1. In Server Manager, click the Manage menu and then click Remove Roles and
Features.
2. Click Next on the “Before you begin” page, if applicable.
3. Select the destination server that you want to demote and then click Next.
4. Deselect the Active Directory Domain Services role. In the corresponding pop-up
dialog box, click Remove Features to also remove the management tools.
5. A validation process will display an error indicating that the domain controller must
be demoted before the Active Directory Domain Services role can be removed.
Click “Demote this domain controller” in the validation box.
6. Specify credentials to perform the operation or accept the default of the currently
logged on user, and then click Next.
7. Click to select the “Proceed with removal” option and then click Next.
8. If you want to retain the domain controller metadata, select the option to retain.
Click Next.
9. Type in and confirm a new password for the local Administrator account. Click
Next.
66 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
92
|
10. Review the options and then click Demote.
Using PowerShell
1. Open PowerShell on the domain controller to be demoted.
2. Run the Uninstall-ADDSDomainController command.
3. Supply a new password for the local Administrator account.
4. Type Y and press Enter to confirm the operation. Note that the server will reboot
after completing the demotion process.
Discussion
Before demoting a domain controller, you first need to ensure that all of the FSMO roles
have been transferred to other servers; otherwise, they will be transferred to random
domain controllers that may not be optimal for your installation. (Managing FSMO
role holders is discussed in Recipe 3.29.) Also, if the DC is a global catalog server or
running a service such as DNS, WINS, DHCP, and so on, ensure that you have sufficient
GCs and other infrastructure servers elsewhere in your forest that can handle the in‐
creased load.
It is important to demote a domain controller before decommissioning or rebuilding it
so that its associated objects in Active Directory are removed, its SRV locator resource
records are dynamically removed, and replication with the other domain controllers is
not interrupted. If a domain controller does not successfully demote, or if you do not
get the chance to demote it because of some type of hardware failure, see Recipe 2.4 for
removing a domain from Active Directory and Recipe 3.6 for instructions on manually
removing a domain controller from Active Directory.
See Also
Recipe 2.4; Recipe 3.6; Recipe 3.10 for removing an unsuccessfully demoted domain
controller; Recipe 3.22 for disabling the global catalog; Recipe 3.29; Recipe 3.30 for
transferring FSMO roles
3.7. Automating the Promotion or Demotion of a
Domain Controller
Problem
You want to automate the installation or removal of a domain controller.
3.7. Automating the Promotion or Demotion of a Domain Controller | 67
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
93
|
Solution
You can automate the promotion of a domain controller by using PowerShell. Use the
Install-ADDSDomainController cmdlet, as shown in the following example:
Import-Module ADDSDeployment
Install-ADDSDomainController↵
-CreateDNSDelegation↵
-Credential (Get-Credential)↵
-CriticalReplicationOnly:$false↵
-DatabasePath "D:\NTDS\DB"↵
-LogPath "E:\NTDS\Logs"↵
-DomainName "adatum.com"↵
-InstallDNS:$true↵
-SiteName "Default-First-Site-Name"↵
-SYSVOLPath "C:\Windows\SYSVOL"↵
-Force:$true
You can automate the demotion of a domain controller by using the UninstallADDSDomainController cmdlet. The cmdlet can be run locally, with the only require‐
ment being to enter a local administrator password, or it can be run against a remote
domain controller as noted in the following section.
Discussion
To remotely install a domain controller by using PowerShell, use the Invoke-Command
cmdlet to kick off a command on a remote computer, as shown in the following syntax:
Invoke-Command {<PowerShell command>} -ComputerName <RemoteHost>
See Also
“Create an Answer File for Unattended Domain Controller Installation”
3.8. Troubleshooting Domain Controller Promotion or
Demotion Problems
Problem
You are having problems promoting or demoting a domain controller and you want to
troubleshoot it.
Solution
The best sources of information about the status of promotion or demotion problems
are the Dcpromo.log and Dcpromoui.log files contained in the %SystemRoot%\Debug
folder on the server. The Dcpromo.log file captures the input entered into dcpromo and
68 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
94
|
logs the information that is displayed as dcpromo progresses. The Dcpromoui.log file is
much more detailed and captures discrete actions that occur during dcpromo process‐
ing, including any user input. A sample dcpromoui.log file might look something like
this:
dcpromoui 404.554 0000 11:09:01.479 opening log file↵
C:\Windows\debug\dcpromoui.log dcpromoui 404.554 0001 11:09:01.479↵
C:\Windows\system32\wsmprovhost.exe dcpromoui 404.554 0002 11:09:01.479↵
file timestamp 07/25/2012 20:08:53.059 dcpromoui 404.554 0003 11:09:01.479↵
C:\Windows\system32\dcpromocmd.dll dcpromoui 404.554 0004 11:09:01.479↵
file timestamp 07/25/2012 20:05:25.050 dcpromoui 404.554 0005 11:09:01.479↵
local time 09/27/2012 11:09:01.479 dcpromoui 404.554 0006 11:09:01.480↵
running Windows NT 6.2 build 9200 (BuildLab:9200.win8_rtm.120725-1247) amd64↵
...
dcpromoui AD0.BD0 087D 20:03:51.337 exitCode = 55
dcpromoui AD0.BD0 087E 20:03:51.337 Enter State::UnbindFromReplicationPartnetDC
dcpromoui AD0.BD0 087F 20:03:51.368 closing log
Additionally, dcdiag contains two tests that can aid in troubleshooting promotion prob‐
lems. The dcpromo test reports anything it finds that could impede the promotion pro‐
cess. The RegisterInDNS test checks whether the server can register records in DNS.
Here is an example of running both commands to test against the adatum.com domain
(note that the /ReplicaDC parameter is specific to a scenario where you want to add an
additional domain controller to an existing domain):
> dcdiag /test:dcpromo /DnsDomain:adatum.com /ReplicaDC /test:RegisterInDNS
Discussion
In most cases, the level of detail provided by Dcpromoui.log should be sufficient to
pinpoint any problems, but you can increase logging if necessary. To enable the highest
level of logging available, set the following registry value to FF0003: HKLM\Software
\Microsoft\Windows\CurrentVersion\AdminDebug. You can confirm that this mask
took effect by running a promotion again, checking Dcpromoui.log, and searching for
“logging mask.”
If dcdiag does not return sufficient information, the Network Monitor (netmon) pro‐
gram is very handy for getting a detailed understanding of the network traffic that is
being generated and any errors that are being returned. Network Monitor is available
as a free download from the Microsoft website. Using Network Monitor, you can identify
what other servers a DC is communicating with or if it is timing out when attempting
to perform certain queries or updates.
See Also
MS KB 221254 (Registry Settings for Event Detail in the Dcpromoui.log File); “Active
Directory Diagnostic Logging”
3.8. Troubleshooting Domain Controller Promotion or Demotion Problems | 69
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
95
|
3.9. Verifying the Promotion of a Domain Controller
Problem
You want to verify that a domain controller has been successfully promoted within an
Active Directory domain.
Solution
Using a command-line interface
> dcdiag /test:replications
> dcdiag /s:<DCName> /test:knowsofroleholders
> dcdiag /s:<DCName> /test:fsmocheck
Discussion
Once you’ve installed a domain controller, there are several steps that you can take to
ensure that the promotion process has completed successfully. Since Windows Server
2008, dcdiag.exe has been built directly into the AD DS binaries; netdiag.exe is no longer
supported. Regardless of the version of the server operating system, dcdiag and net‐
diag can perform a number of diagnostic tests, including the following:
• Verify that all necessary DNS records have been registered and are present on the
DNS server.
• Check the domain membership for the newly promoted computer.
• Confirm that the new DC can communicate with other DCs in the domain.
• Confirm that the new DC is replicating with other DCs.
• Verify that the new DC can communicate with all of the FSMO role holders.
In addition, you can verify a successful domain controller promotion by verifying that
it is responding on TCP ports 389 and 3268, running dcdiag /replsum, confirming that
the SYSVOL directory has been shared, as well as checking the Directory Service log in
the Event Viewer for any errors or warnings.
See Also
“Dcdiag”
70 | Chapter 3: Domain Controllers, Global Catalogs, and FSMOs
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.