index
int64 0
4.08k
| text
stringlengths 34
4.9k
⌀ | url
stringclasses 38
values |
|---|---|---|
596
|
Set-ADObject "cn=NTDS Quotas,<PartitionDN>"↵
-Replace @{"msDS-DefaultQuota"="<QuotaValue>"}
Discussion
The easiest way to apply a default quota to all of your users is to modify the msDSDefaultQuota attribute on the NTDS Quotas container for the target partition. This
attribute contains the default quota limit that is used if no other quotas have been
assigned to a security principal. A value of −1 means that no quota exists; security prin‐
cipals can create and/or tombstone as many objects as they wish.
You should be careful when setting the default quota because it applies to every non‐
administrator security principal. If you set the default to 0, for example, computers
would not be able to dynamically update their DNS records in an AD integrated zone
because that creates an object. This may not be applicable in your environment, but the
point is that you need to consider the impact of the default quota and test it thoroughly
before implementing it.
15.19. Finding the Quota Usage for a Security Principal
Problem
You want to find the quota usage for a certain security principal.
Solution
Using a command-line interface
The quota usage of a security principal can be determined a few different ways. First,
you can use DSGet. Here is an example:
> dsget user "<UserDN>" -part <PartitionDN> -qlimit -qused
This displays the effective quota limit and how much of the quota has been used for a
particular user. You can use similar parameters with dsget computer and dsget
group to find the quota usage for those types of objects.
Users can find their own quota usage by querying the msDs-QuotaUsed and msDsQuotaEffective attributes on the cn=NTDS Quotas container for a partition. These two
attributes are constructed, which means they are dynamically calculated based on the
user that is accessing them (see Recipe 10.14 for more on constructed attributes). The
msDs-QuotaUsed attribute returns how much of the quota has been used by the user,
and the msDs-QuotaEffective attribute contains the quota limit.
15.19. Finding the Quota Usage for a Security Principal | 571
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
597
|
Using PowerShell
Alternatively, view the msDs-TopQuotaUsage attribute on a partition’s cn=NTDS Quo
tas container, which contains the users with the top quota usage. This attribute is mul‐
tivalued, with each value being XML-like text that contains the SID and how much of
the quota the principal has used. To view the quota usage, use the following command:
Get-ADObject "cn=NTDS Quotas,<PartitionDN>" -Properties msds-TopQuotaUsage
Discussion
If you implement quotas, you’ll certainly need to tell users what their quotas are (or
provide instructions on how they can find out for themselves). Currently, there are a
few ways to determine quota usage, as outlined in this recipe’s “Solution” section.
Perhaps the most interesting is obtaining the top-quota usage. Note that it contains
quota usage for all objects, even if the objects don’t have a quota. Each value of the msDsTopQuotaUsage attribute contains an entry that details the top quota users in the data‐
base, listed in decreasing order of quota usage. Each value of the msDsTopQuotaUsage attribute contains blocks of data formatted in an XML-like language.
Each block has the SID of the security principal (<ownerSID>), quota used (<quo
taUsed>), number of tombstone objects created (<tombstonedCount>), and number of
objects that are still active (<liveCount>) (i.e., not tombstoned). Here is an example of
what the attribute can contain:
DistinguishedName : cn=NTDS Quotas,dc=adatum,dc=com
msds-TopQuotaUsage : {
<MS_DS_TOP_QUOTA_USAGE>
<partitionDN> dc=adatum,dc=com </partitionDN>
<ownerSID> S-1-5-32-548 </ownerSID>
<quotaUsed> 10003 </quotaUsed>
<deletedCount> 7 </deletedCount>
<liveCount> 10001 </liveCount>
</MS_DS_TOP_QUOTA_USAGE>
,
<MS_DS_TOP_QUOTA_USAGE>
<partitionDN> dc=adatum,dc=com </partitionDN>
<ownerSID>↵
S-1-5-21-1553546772-1433447814-1030694943-512 </ownerSID>
<quotaUsed> 240 </quotaUsed>
<deletedCount> 14 </deletedCount>
<liveCount> 237 </liveCount>
</MS_DS_TOP_QUOTA_USAGE>
,
<MS_DS_TOP_QUOTA_USAGE>
<partitionDN> dc=adatum,dc=com </partitionDN>
<ownerSID> S-1-5-18 </ownerSID>
<quotaUsed> 37 </quotaUsed>
<deletedCount> 32 </deletedCount>
<liveCount> 32 </liveCount>
572 | Chapter 15: Logging, Monitoring, and Quotas
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
598
|
</MS_DS_TOP_QUOTA_USAGE>
,
<MS_DS_TOP_QUOTA_USAGE>
<partitionDN> dc=adatum,dc=com </partitionDN>
<ownerSID> S-1-5-32-544 </ownerSID>
<quotaUsed> 21 </quotaUsed>
<deletedCount> 0 </deletedCount>
<liveCount> 21 </liveCount>
</MS_DS_TOP_QUOTA_USAGE>
...}
Name : NTDS Quotas
ObjectClass : msDS-QuotaContainer
ObjectGUID : c4bad721-caa3-4893-9bf5-cf399edca9aa
Additionally, AdFind has switches that can decode this output in a much friendlier
format, as follows:
adfind -b "cn=NTDS Quotas, <PartitionDN>" msDs-TopQuotaUsage;binary -resolvesids
This command will return results similar to the following:
cn=NTDS Quotas,dc=adatum,dc=com
> msDs-TopQuotaUsage;binary: NC: dc=adatum,dc=com Owner: ADATUM\Domain Admins
Used:175 Tombstone: 0 LiveCount: 175
cn=NTDS Quotas,dc=adatum,dc=com
> msDs-TopQuotaUsage;binary: NC: dc=adatum,dc=com Owner: NT AUTHORITY\SYSTEM↵
Used:
62 Tombstone: 29 LiveCount: 33
> msDs-TopQuotaUsage;binary: NC dc=adatum,dc=com Owner: BUILTIN\Administrators
Used: 14 Tombstone: 0 LiveCount: 14
See Also
Recipe 15.16 for more on finding the quotas that are assigned to a security principal
15.19. Finding the Quota Usage for a Security Principal | 573
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
599
| null |
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
600
|
CHAPTER 16
Backup, Recovery, DIT Maintenance, and
Deleted Objects
16.0. Introduction
The AD Directory Information Tree (DIT) is implemented as a transactional database
using the Extensible Storage Engine (ESE). The primary database file is named ntds.dit
and is stored in the %SystemRoot%\NTDS folder by default, but it can be relocated
during the initial promotion process or manually via ntdsutil (see Recipe 16.11 for more
details).
Each database write transaction is initially stored in a logfile named edb.log, which is
stored in the same directory as ntds.dit by default, though you can modify this either
during or after the initial promotion process. That logfile can grow to 10 MB in size,
after which additional logfiles are created (e.g., edb00001.log), each of which can also
grow to up to 10 MB in size. After the transactions in the logfiles are committed to the
database, the logfiles are purged, beginning with the log containing the oldest transac‐
tions. This process is referred to as circular logging. These logfiles are useful when a
domain controller is shut down unexpectedly because when the DC comes back online,
Active Directory can replay the logfiles and apply any transactions that might not have
been written to disk before the DC shut down. The edb.chk file stores information about
the last transaction that was actually committed to the database; AD uses this informa‐
tion to determine which transactions in the logfiles still need to be committed. Finally,
two 10 MB files called edbres00001.jrs and edbres00002.jrs are used as placeholders in
case the disk runs out of space; if this happens, these files are deleted to free up enough
space to allow Active Directory to commit any final changes before the DC is shut down.
In order to recover portions of Active Directory, or the entire directory itself, you need
to have a solid backup strategy in place. You can back up Active Directory while it is
online, which means you do not need to worry about scheduling regular downtime
575
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
601
|
simply to perform backups. Restoring Active Directory is also a relatively simple pro‐
cess. You can restore a single object, an entire subtree, or the entire database if necessary.
For a detailed discussion on backing up and restoring Active Directory, see Active Di‐
rectory, Fifth Edition, by Brian Desmond et al. (O’Reilly).
You also need to be familiar with how deleted objects are treated in Active Directory,
which can affect your backup procedures. By default, the Active Directory Recycle Bin
is not enabled. When the Active Directory Recycle Bin is not enabled and an object is
requested to be deleted, it is actually marked as a tombstone and moved to the Deleted
Objects container. This tombstone object has most of the original object’s attribute val‐
ues removed to save space in the NTDS.DIT file. These objects are stored in the cn=De
leted Objects container in the naming context that the original object was located in.
The deleted object is named using the following format: <OrigName>\0ADEL: <Object
GUID>, where <OrigName> is the original RDN of the object, <ObjectGUID> is the GUID
of the object, and \0A is a null-terminated character. For example, if you deleted the
jsmith user object, its tombstone object would have a distinguished name similar to
the following:
cn=jsmith\0ADEL:fce1ca8e-a5ec-4a29-96e1-c8013e533d2c,cn=Deleted↵
Objects,dc=adatum,dc=com
If the Active Directory Recycle Bin is enabled, a deleted object becomes logically deleted
while the link-valued and non-link-valued attributes are maintained. Thus, during the
deleted object lifetime, deleted objects can be restored to the exact state that they were
in prior to the deletion. (This includes group membership information, too.) The restore
process for deleted objects becomes much simpler and cleaner with the Active Directory
Recycle Bin.
In Windows Server 2012, the AD DS service can be stopped to perform some (but not
all) maintenance operations without needing to reboot the domain controller into
DSRM. Some of the operations you can perform on a 2012 DC while the AD DS service
is stopped include:
• Performing an offline defragmentation.
• Moving the AD database files.
• Performing a nonauthoritative restore. However, performing an authoritative re‐
store still requires a full reboot into DSRM.
You can stop the Active Directory Domain Services service using familiar interfaces
such as the Services MMC snap-in, Server Manager, the net stop command-line utility,
or the Stop-Service PowerShell cmdlet. Be aware that when you stop the Active Di‐
rectory Domain Services service, one or more of the following dependent services will
be stopped as well; you will need to take this into consideration when restarting the AD
DS service so that all associated services are also restarted:
576 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
602
|
• File Replication
• Kerberos Key Distribution Center
• Intersite Messaging
• DNS Server (on DCs that are running the DNS Server service)
• DFS Replication
After a period of time known as the tombstone lifetime (180 days is the default for
Windows Server 2012), the tombstone object is finally removed from Active Directory.
At that point, remnants of the former object do not exist in Active Directory.
Tombstone objects are important to understand with regard to your backup strategy
because you should not keep backups longer than the tombstone lifetime. If you attempt
to restore a backup that is older than the tombstone lifetime, it may introduce objects
that were deleted but for which a tombstone object no longer exists. Under normal
conditions, if you do a nonauthoritative restore from backup, objects that were valid
when the backup was taken but that were subsequently deleted will be deleted during
the first replication cycle after the DC is rebooted normally. If the tombstone object has
already expired (e.g., the backup is older than 180 days), Active Directory has no way
to determine whether the object was previously deleted and will read it. Reinjected
deleted objects are referred to as lingering or zombie objects.
The tombstone lifetime value is stored in the tombstoneLifetime attribute on the fol‐
lowing object: cn=Directory Service,cn=Windows NT,cn=Services,cn=Configura
tion, <ForestRootDN>.
The Anatomy of a Deleted Object
Deleted objects are generally stored in the respective Deleted Objects container of
their naming context. You can view deleted objects by using the Active Directory Ad‐
ministrative Center and browsing to the Deleted Objects container. Table 16-1 con‐
tains some of the attributes that are stored with deleted objects.
The attributes that are preserved in tombstone objects are determined
by attributeSchema objects that have bit 3 enabled (8 in decimal) in
the searchFlags attribute.
16.0. Introduction | 577
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
603
|
Table 16-1. Useful attributes of deleted objects
Attribute Description
isDeleted The value for this attribute is TRUE for deleted objects.
isRecycled The value for this attribute is TRUE for deleted objects that have had their deleted object lifetime
expire.
lastKnownParent Distinguished name of container the object was contained in.
Name RDN of the object’s current location.
userAccountControl This attribute is retained when the original object is deleted. This applies only to user and
computer objects.
objectSID This attribute is retained when the original object is deleted. This applies only to user and
computer objects.
sAMAccountName This attribute is retained when the original object is deleted. This applies only to user and
computer objects.
sidHistory This attribute is retained when the original object is deleted. This applies only to user and
computer objects.
To aid in Active Directory backup and recovery, Windows Server 2012 includes a snap‐
shot feature that allows you to take point-in-time snapshots of the Active Directory
database and then mount those snapshots to view the contents and compare them to
the current contents of the AD database. Using scripts or third-party tools, you can even
copy information from an Active Directory snapshot directly into the live AD database
without needing to reboot the domain controller to perform a traditional restore
operation.
16.1. Backing Up the Active Directory Database
Problem
You want to back up the Active Directory database.
Solution
Using a command-line interface
> wbadmin start systemstatebackup -backuptarget:"<BackupTarget>"
Using Windows PowerShell
The following PowerShell example will start a one-time System State backup, saving the
backup data on the E:\ volume.
$wbPolicy = New-WBPolicy
Set-WBSchedule -Policy $wbPolicy -Schedule 23:59
Add-WBSystemState -Policy $wbPolicy
578 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
604
|
$wbTarget = New-WBBackupTarget -VolumePath E:
Add-WBBackupTarget -Policy $wbPolicy -Target $wbTarget
Start-WBBackup -Policy $wbPolicy
Discussion
The wbadmin command can be used to create a System State backup of the Active Di‐
rectory database. In addition, there is a Windows Server Backup GUI tool that can be
used to perform the backup. Alternately, Windows PowerShell cmdlets are available to
configure one-time and scheduled backup jobs. The steps in this recipe assume that you
have installed the Windows Server Backup feature. To install the Windows Server Back‐
up feature using PowerShell, run the following command.
Add-WindowsFeature Windows-Server-Backup -IncludeAllSubFeature
See Also
Recipe 16.2 for information on creating Active Directory snapshots; Recipe 16.3 for
more on mounting and using snapshots
16.2. Creating an Active Directory Snapshot
Problem
You want to create a snapshot of the Active Directory database.
Solution
Using a command-line interface
> ntdsutil
> activate instance ntds
> snapshot
> create
Discussion
The Active Directory Domain Services snapshot feature leverages the Volume Shadow
Copy Service (VSS) to allow administrators to create “shadow copies” of the Active
Directory database. Once a snapshot has been created, you can use the ntdsutil and
dsamain command-line utilities to mount the snapshot as a read-only copy of the Active
Directory database. Once the snapshot is mounted, you can view it using customary
tools such as ADSI Edit and LDP, as well as using third-party tools to copy information
from a snapshot into a live Active Directory database.
16.2. Creating an Active Directory Snapshot | 579
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
605
|
See Also
Recipe 16.3 for more on mounting and using snapshots
16.3. Mounting an Active Directory Snapshot
Problem
You want to mount a snapshot of the Active Directory database that you created pre‐
viously using either ntdsutil or a System State backup.
Solution
Using a command-line interface
If you want to view a snapshot in ntdsutil, you must first mount the snapshot within
ntdsutil as follows:
> ntdsutil
> activate instance ntds
> snapshot
> list all
The list all command generates a list of snapshots that have been created on the
domain controller in question, each with a corresponding number. You will then issue
the mount<Number> command to mount the snapshot that you want. Once the snapshot
is mounted, ntdsutil will list the physical path that the database has been mounted to,
such as C:\$SNAP_200808011002_VOLUMEC$\.
Once you have mounted the snapshot you want, you’ll use the dsamain command to
expose the snapshot as an LDAP server. When using dsamain, you will need to provide
an alternate LDAP port since 389 is in use by the live AD database. You can also specify
an alternate LDAPS port, Global Catalog port, and secure Global Catalog port. Use the
dsamain tool as follows:
> dsamain /dbpath "<Path to database file>" /ldapport <Port Number>
The mounted snapshot will be exposed as an LDAP server as long as the command
window remains open. Use Ctrl-C to “switch off ” the snapshot functionality.
Discussion
The dsamain utility can be used to expose an Active Directory snapshot that has been
created using ntdsutil, or it can use the contents of a System State backup that has been
restored to an alternate location on the local hard drive. Network or UNC paths are not
supported. Once a snapshot or restored backup is exposed using dsamain, it can be
580 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
606
|
accessed in a read-only manner using Active Directory tools such as LDP or ADSI Edit,
as well as scripts and PowerShell.
See Also
Recipe 16.2 for more on creating snapshots; Recipe 16.4 for more on accessing and
manipulating information contained in a snapshot
16.4. Accessing Active Directory Snapshot Data
Problem
You want to access data contained within a snapshot of the Active Directory database
that you created previously using either ntdsutil or a System State backup.
Solution
Using a graphical user interface
1. Launch LDP.exe and then connect to the server with a snapshot mounted, using
the appropriate port number.
2. Select Connection→Bind and then click OK.
3. Click View→Tree. Select the Base DN you would like to view snapshot data from.
4. Expand the snapshot tree to view the containers and objects available in the snap‐
shot.
Using Windows PowerShell
Get-ADObject -Identity "<ObjectDN>" -Server <ServerName>:<PortNumber>↵
-Properties * | FL
Discussion
An Active Directory snapshot provides a read-only view of the Active Directory data‐
base as it existed at a particular point in time, whether the snapshot was created using
ntdsutil or whether you are using dsamain to mount the ntds.dit contained in a System
State backup. While Windows does not provide a method to perform a simple GUI “cutand-paste” to insert values from a snapshot into a live Active Directory database, you
can do so using scripting, PowerShell, or a third-party tool. You can also view the con‐
tents of a snapshot using tools such as ADSI Edit by simply indicating the alternate
LDAP port number that you specified when you mounted the snapshot.
16.4. Accessing Active Directory Snapshot Data | 581
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
607
|
See Also
Recipe 16.3 for more on mounting and using snapshots; “Active Directory Explorer
v1.14” (another tool for working with snapshots)
16.5. Restarting a Domain Controller in Directory Services
Repair Mode
Problem
You want to restart a domain controller in DS Repair Mode.
Solution
To enter DS Repair Mode, press F8 after the power-on self-test (POST), which will bring
up a menu, as shown in Figure 16-1. From the menu, select Directory Services Repair
Mode.
Figure 16-1. Boot options
582 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
608
|
Using a graphical user interface
1. Run msconfig.exe and then select the Boot tab.
2. Place a checkmark in the Safe Boot option and then select the Active Directory
repair option.
3. Click OK. You will be prompted to restart the server.
Using the command-line interface
You can also enable DSRM prior to rebooting a server by entering the following
command:
> bcdedit /set safeboot dsrepair
Once you have completed the maintenance on the DC and wish to return to a normal
startup mode, enter the following prior to rebooting:
> bcdedit /deletevalue safeboot
Discussion
The Active Directory database is live and locked by the system whenever a domain
controller is booted into normal mode. In DS Repair Mode, Active Directory does not
start up and the database files (e.g., ntds.dit) are not locked. The restartable AD DS
service allows you to perform certain maintenance tasks, such as performing an offline
defrag, without needing to reboot the domain controller into DSRM. However, certain
critical operations, such as an authoritative restore, still need to be performed in Di‐
rectory Services Repair Mode.
It is not always practical to be logged in to the console of the server when you need to
reboot it into DS Repair Mode. You can use Remote Desktop Connection to log on to
the machine remotely while it is in DSRM mode.
Directory Services Repair Mode was referred to as Directory Services
Restore Mode in previous versions of Windows.
See Also
“Restart the Domain Controller in Directory Services Restore Mode Remotely”
16.5. Restarting a Domain Controller in Directory Services Repair Mode | 583
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
609
|
16.6. Resetting the Directory Services Repair Mode
Administrator Password
Problem
You want to reset the DS Repair Mode administrator password. This password is set
individually (i.e., not replicated) on each domain controller and is initially configured
when you promote a server to a domain controller.
Solution
Using a command-line interface
Using ntdsutil, you can change the DS Repair Mode administrator password of a domain
controller while it is live (i.e., not in DS Repair Mode). Another benefit of this option
is that you can run it against a remote domain controller. Use the following command
sequence to reset the password on a domain controller named DC1:
> ntdsutil
> set dsrm password
> reset password on server DC1
However, if you are already in DSRM and would like to change the password, the ntdsutil
option is not available. To change the DSRM password once you are already logged in,
use the following command:
net user Administrator "<Password>"
Discussion
You may be thinking that having a separate DS Repair Mode administrator password
can be quite a pain. Yet another thing you have to maintain and update on a regular
basis, right? But if you think about it, you’ll see that it is quite necessary.
Generally, you boot a domain controller into DS Repair Mode when you need to perform
some type of maintenance on the Active Directory database. To do this, the database
needs to be offline. But if the database is offline, then there is no way to authenticate
against it. Because of this, the system has to use another authentication repository, so it
reverts back to the legacy SAM database. The DS Repair Mode administrator account
and password are stored in the SAM database, just as with standalone Windows servers.
The one disadvantage to the solutions presented in this recipe is that you have to reset
the DSRM password on one machine at a time. To automate this process on all domain
controllers, the following PowerShell command will synchronize the DSRM password
with the current password of the domain Administrator account:
584 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
610
|
Get-ADDomainController -Filter * | ForEach-Object {Invoke-Command↵
-ComputerName $_.Name -ScriptBlock {ntdsutil "set dsrm password"↵
"sync from domain account Administrator" "Q" "Q"}}
See Also
TechNet Article cc754363, “set DSRM password” for resetting the DSRM password on
a domain controller
16.7. Performing a Nonauthoritative Restore
Problem
You want to perform a nonauthoritative restore of a domain controller. This can be
useful if you want to quickly restore a domain controller that failed due to a hardware
problem.
Solution
Using a command-line interface
To perform a system state recovery, you will need to know the date and timestamp of
the system state backup that you want to recover from. You can perform a nonauthor‐
itative restore by rebooting the DC into DSRM or by stopping the Active Directory
Domain Services service; you can stop this service from the Services MMC snap-in,
from Server Manager, or by using the net stop command-line utility. The following
command syntax performs a system state recovery:
> wbadmin start systemstaterecovery -version:<BackupDate>-<BackupTime>
Discussion
If you encounter a failed domain controller that you cannot bring back up (e.g., multiple
hard disks fail), you have two options for restoring it. One option is to remove the
domain controller completely from Active Directory (as outlined in Recipe 3.10) and
then promote it back in. This is known as the restore from replication method, because
you are essentially bringing up a brand-new domain controller and letting replication
restore all the data on the server. After performing the steps described in Recipe 3.10,
you can also use the Install From Media option described in Recipe 3.5 to expedite this
process.
The other option is described in this recipe’s solution. You can restore the domain con‐
troller from a good backup. This method involves restoring the System State and any
necessary system drive(s) and then rebooting. As long as the domain controller comes
up clean, it should start participating in Active Directory replication once again and
16.7. Performing a Nonauthoritative Restore | 585
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
611
|
replicate any changes that have occurred since the backup was taken. This method is
generally the fastest for restoring a domain controller, particularly if the server is the
only DC located in a remote site.
For a detailed discussion of the advantages and disadvantages of each option, see Active
Directory, Fifth Edition, by Brian Desmond et al. (O’Reilly).
See Also
Recipe 16.5 for getting into Directory Services Repair Mode
16.8. Performing an Authoritative Restore of an Object
or Subtree
Problem
You want to perform an authoritative restore of one or more objects, but not the entire
Active Directory database. For the GUI solution, this recipe assumes that the Active
Directory Recycle Bin was enabled prior to the deletion. If you have not enabled the
AD Recycle Bin, you can do so from the Tasks pane in the Active Directory Adminis‐
trative Center.
Solution
Using a graphical user interface (steps specific to Windows Server 2012)
1. Launch Active Directory Administrative Center.
2. Select the domain and navigate to the Deleted Objects container.
3. Locate the deleted object in the container.
4. Right-click the object and select Restore.
Using a command-line interface
To restore a single object, run the following commands:
> ntdsutil
> activate instance ntds
> auth restore
> restore object cn=jsmith,ou=Sales,dc=adatum,dc=com
> q
To restore an entire subtree, run the following commands:
> ntdsutil
> activate instance ntds
586 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
612
|
> auth restore
> restore subtree ou=Sales,dc=adatum,dc=com
> q
Restart the computer.
There are some issues related to restoring user, group, computer, and trust objects that
you should be aware of. See MS KB 216243 and MS KB 280079 for more information.
Using PowerShell
Get-ADObject -Filter {isDeleted -eq $true} -IncludeDeletedObjects |↵
Where-Object {$_.DistinguishedName -match "<GroupName>"} | Restore-ADObject
Discussion
If an administrator or user accidentally deletes an important object or entire subtree
from Active Directory, you can restore it. Fortunately, the process isn’t very painful. The
key is to have a good backup that contains the objects you want to restore.
Using a command-line interface
To restore one or more objects, you need to follow the same steps as when performing
a nonauthoritative restore. The only difference is that after you do the restore, you need
to use ntdsutil to mark the objects in question as authoritative on the restored domain
controller. After you reboot the domain controller, it will then receive information from
its replication partners and process updates for any objects that have been changed since
the backup that was restored on the machine, except for the objects or subtrees that
were marked as authoritative. For those objects, Active Directory modifies the restored
objects in such a way that they will become authoritative and replicate out to the other
domain controllers.
Performing an authoritative restore of user or group objects will require
additional considerations, as detailed in MS KB 280079. (Authoritative
restore of groups can result in inconsistent membership information
across domain controllers.)
You can also use ntdsutil without first doing a restore in situations where an object has
accidentally been deleted, but the change has not yet replicated to all domain controllers.
The trick here is that you need to find a domain controller that has not had the deletion
replicated yet, and either stop it from replicating or make the object authoritative before
it sends its replication updates. Take a look at Recipe 12.5 for more information on
controlling inbound and outbound replication on a domain controller.
16.8. Performing an Authoritative Restore of an Object or Subtree | 587
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
613
|
Using PowerShell
If the Active Directory Recycle Bin is not enabled, then the PowerShell solution will
restore the object without the link-valued and some of the non-link-valued attributes.
However, if the Active Directory Recycle Bin was enabled prior to the object deletion,
then the PowerShell solution will restore the object to its original state, which includes
the link-valued and the non-link-valued attributes.
See Also
Recipe 16.5 for booting into Directory Services Repair Mode; Recipe 16.22 for restoring
a deleted object; MS KB 216243 (Authoritative Restore of Active Directory and Impact
on Trusts and Computer Accounts); MS KB 280079 (Authoritative Restore of Groups
Can Result in Inconsistent Membership Information Across Domain Controllers)
16.9. Performing a Complete Authoritative Restore
Problem
You want to perform a complete authoritative restore of the Active Directory database
because a significant failure has occurred.
Solution
First, reboot into Directory Services Repair Mode (DSRM)—see Recipe 16.5 for more
information. Then, once in DSRM, run the following command to restore the entire
database:
> wbadmin start systemstaterecovery -version:<BackupDate>-<BackupTime>↵
-authsysvol
For example, to restore a backup from 02/14/2013 at 08:56pm, run the following com‐
mand:
> wbadmin start systemstaterecovery -version:02/14/2013-20:56 -authsysvol >↵
activate instance ntds
Restart the computer.
Discussion
In a production environment, you should never have to perform an authoritative restore
of the entire Active Directory database unless you have encountered a drastic situation
such as a forest recovery scenario. It is a drastic measure, and you will almost inevitably
lose data as a result. Before you even attempt such a restore, you may want to contact
Microsoft Support to make sure that all options have been exhausted. However, you
588 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
614
|
should still test the authoritative restore process in a lab environment and make sure
that you have the steps properly documented in case you ever do need to use it.
See Also
Recipe 16.5 for getting into Directory Services Repair Mode; MB KB 216243 (Author‐
itative Restore of Active Directory and Impact on Trusts and Computer Accounts); MS
KB 280079 (Authoritative Restore of Groups Can Result in Inconsistent Membership
Information Across Domain Controllers)
16.10. Checking the DIT File’s Integrity
Problem
You want to check the integrity and semantics of the DIT file to verify that there is no
corruption or bad entries.
Solution
Using a command-line interface
This recipe can be performed while the Active Directory Domain Services service is in
a stopped state; it is not necessary to reboot the DC into DSRM. To stop the AD DS
service, use services.msc, or issue the net stop command.
Once the DC is prepared as needed, run the following commands:
> ntdsutil
> activate instance ntds
> files
> integrity
> quit
> semantic database analysis
> verbose on
> go
> quit
> quit
Discussion
The Active Directory DIT file (ntds.dit) is implemented as a transactional database.
Microsoft uses the ESE database (also called JET Blue) for Active Directory, which has
been used for years in other products such as Microsoft Exchange.
Since the Active Directory DIT is ultimately a database, it can suffer from many of the
same issues as traditional databases. The ntdsutil integrity command checks for
any low-level database corruption and ensures that the database headers are correct and
16.10. Checking the DIT File’s Integrity | 589
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
615
|
the tables are in a consistent state. It reads every byte of the database and can take quite
a while to complete, depending on how large the DIT file is.
Whereas the ntdsutil integrity command verifies the overall structure and health
of the database files, the ntdsutil semantics command looks at the contents of the
database. It will verify, among other things, reference counts, replication metadata, and
security descriptors. If any errors are reported back, you can run go fixup to attempt
to correct them. You should have a recent backup handy before doing this and perform
this step only as a troubleshooting option, preferably under the direction of a Microsoft
PSS engineer, since in the worst case the corruption cannot be fixed or the state of your
AD database may even become worse after the go fixup command completes.
See Also
Recipe 16.5 for booting into Directory Services Repair Mode; MS KB 315136 (How to
Complete a Semantic Database Analysis for the Active Directory Database by Using
Ntdsutil.exe)
16.11. Moving the DIT Files
Problem
You want to move the Active Directory DIT files to a new drive to improve performance
or capacity.
Solution
Using a command-line interface
This recipe can be performed while the Active Directory Domain Services service is in
a stopped state; it is not necessary to reboot the DC into DSRM. Once the service is
stopped, run the following commands, in which <DriveAndFolder> is the new location
where you want to move the files (e.g., d:\NTDS):
> ntdsutil
> activate instance ntds
> files
> move db to "<DriveAndFolder>"
> move logs to "<DriveAndFolder>"
> q
> q
Discussion
You can move the Active Directory database file (ntds.dit) independently of the logfiles.
The first command in the solution moves the database, and the second moves the logs.
590 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
616
|
You may also want to consider running an integrity check against the database after
you’ve moved it to ensure that nothing went wrong during the move. See Recipe 16.10
for more details.
See Also
Recipe 16.5 for booting into Directory Services Repair Mode; Recipe 16.10 for checking
DIT file integrity
16.12. Repairing or Recovering the DIT
Problem
You need to repair or perform a soft recovery of the Active Directory DIT because a
power failure or some other failure caused the domain controller to enter an unstable
state.
Solution
Using a command-line interface
This recipe can be performed while the Active Directory Domain Services service is in
a stopped state; it is not necessary to reboot the DC into DSRM. Once the service is
stopped, run the following commands:
> ntdsutil
> activate instance ntds
> files
> recover
> q
> q
If the recover operation is successful, you should then check the integrity of the AD
database (see Recipe 16.10).
Discussion
Hopefully, you will never need to recover or repair your Active Directory database.
However, a recovery may be needed after a domain controller unexpectedly shuts down,
perhaps due to a power loss, and certain changes were never committed to the database.
When it boots back up, a soft recovery is automatically done in an attempt to reapply
any changes that were contained in the transaction logfiles. Since Active Directory does
this automatically, it is unlikely that running the ntdsutil recover command will be
of much help.
16.12. Repairing or Recovering the DIT | 591
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
617
|
We recommend that you use extreme caution when performing a repair and you may
wish to engage Microsoft Support first in case something goes wrong. If you try the
repair, and it makes things worse, you should consider rebuilding the domain controller
from scratch. See Recipe 3.10 for forcibly removing a failed domain controller from
your domain.
See Also
Recipe 16.10 for checking the integrity of the DIT file
16.13. Performing an Online Defrag Manually
Problem
You want to initiate an online defragmentation to optimize the disk space that’s being
used by the ntds.dit file.
Solution
Using a graphical user interface
1. Open LDP.exe.
2. From the menu, select Connection→Connect.
3. For Server, enter the name of the target domain controller.
4. For Port, enter 389.
5. Click OK.
6. From the menu, select Connection→Bind.
7. Enter the credentials of an administrative user or accept the default and log on with
the current user credentials.
8. Click OK.
9. From the menu, select Browse→Modify.
10. Leave the Dn blank.
11. For Attribute, enter DoOnlineDefrag.
12. For Values, enter 180.
13. For Operation, select Add.
14. Click Enter.
15. Click Run.
592 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
618
|
Using a command-line interface
Create an LDIF file called online_defrag.ldf with the following contents:
dn:
changetype: modify
replace:DoOnlineDefrag
DoOnlineDefrag: 180
-
Then run the following command:
> ldifde -v -i -f online_defrag.ldf
You can also perform an online defrag using AdMod:
> admod -b "" doOnlineDefrag::180
Using PowerShell
$rootDSE = [ADSI] "LDAP://<DomainControllerName>/RootDSE"
$rootDSE.put("DoOnlineDefrag", "180")
$rootDSE.SetInfo()
Discussion
By default, the online defrag process runs every 12 hours on each domain controller
after the garbage collection process completes. This process defrags the Active Directory
database (ntds.dit) by combining whitespace generated from deleted objects but does
not reduce the size of the database file.
To start an online defrag, simply write the DoOnlineDefrag attribute to the RootDSE
with a value equal to the maximum time the defrag process should run (in seconds).
You must be a member of the Domain Admins group in the domain controller’s domain
in order to write to this attribute.
See Also
Recipe 16.17 for performing an offline defrag; MS KB 198793 (The Active Directory
Database Garbage Collection Process)
16.14. Performing a Database Recovery
Problem
You want to perform a recovery of the Active Directory database when other methods
have failed.
16.14. Performing a Database Recovery | 593
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
619
|
Solution
Using a command-line interface
This recipe can be performed while the Active Directory Domain Services service is in
a stopped state; it is not necessary to reboot the DC into DSRM. Once the service is
stopped, to perform an integrity check of the Active Directory database, enter the fol‐
lowing:
> esentutl /g "<PathToNTDS.DIT>"/!10240 /8 /o
To perform a recovery of the AD database, enter the following:
> esentutl /r "<PathToNTDS.DIT>" /!10240 /8 /o
To perform a repair of the database, use the following syntax:
> esentutl /p "<PathToNTDS.DIT>" /!10240 /8 /o
Discussion
When attempting to recover the ntds.dit database, you may occasionally encounter a
situation where ntdsutil is unable to repair whatever damage has occurred. You may run
into error messages similar to the following:
Operation failed because the database was inconsistent.
Initialize jet database failed; cannot access file.
Error while performing soft recovery.
Because the AD database is based on the ESE, you also have access to the esentutl
database utility, which can perform a number of operations against the ntds.dit file,
including defragmentation, database recovery or repair, and integrity checks. (For a
complete description of each operation, type esentutl /? at the command line.)
If the ntdsutil recovery options listed elsewhere in this chapter fail, you can attempt to
repair AD using this ESE utility. Many of the operations that you can perform with
esentutl have the potential to exacerbate data loss, so be certain that you have a viable
backup in place before attempting any of them. In fact, in some cases it may actually be
easier and quicker to simply restore from a known good backup to get your domain or
forest back online again.
See Also
MS KB 305500 (Cannot Repair the Active Directory Database by Using the Ntdsutil
Tool); MS KB 280364 (How to Recover from Event ID 1168 and Event ID 1003 Error
Messages)
594 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
620
|
16.15. Creating a Reserve File
Problem
You want to create another reserve file on the disk containing the ntds.dit file to guard
against AD failures caused by running out of disk space.
Solution
Using a command-line interface
The following command will create an empty reserve file, 250 MB in size, in the same
directory as the ntds.dit file:
> fsutil file createnew <PathToNTDS.DIT>\reservefile 256000000
For example, the following will create the reserve file in c:\windows\ntds:
> fsutil file createnew c:\windows\ntds\reservefile 256000000
Discussion
By default, Active Directory creates two files called ebdres00001.jrs and ed
bres00002.jrs in the same directory as the ntds.dit database. Each of these files is 10 MB
in size and is used to hold in reserve the last 20 MB of space on the drive hosting the
AD database files. If a domain controller runs out of space on that drive, Active Directory
will use the space being held by ebdres00001.jrs and edbres00002.jrs to commit any
uncommitted transactions before shutting down so that no information is lost. If you
wish to set aside more space than this, you can create a reserve file to set aside additional
space; this reserve file can then be manually deleted to free up disk space. This can
provide an additional safeguard against a user or administrator inadvertently filling up
the drive that’s hosting the ntds.dit file, or guard against a virus or a malicious user
performing a denial-of-service attack by intentionally filling up the drive.
To prevent accidental or malicious bloating of the ntds.dit file itself, you
can also establish quotas to restrict the number of objects that can be
created by a user.
See Also
Recipe 15.15 for more on creating Active Directory quotas; Recipe 15.17 for configuring
how tombstoned objects affect quotas
16.15. Creating a Reserve File | 595
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
621
|
16.16. Determining How Much Whitespace Is in the DIT
Problem
You want to find the amount of whitespace in your DIT. A lot of whitespace in the DIT
may mean that you could regain enough space on the disk to warrant performing an
offline defrag.
Solution
Using a graphical user interface
1. Run regedit.exe from the command line or from Start→Run.
2. Expand HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS
\Diagnostics.
3. In the right pane, double-click on 6 Garbage Collection.
4. For Value data, enter 1.
5. Click OK.
Using a command-line interface
> reg add HKLM\System\CurrentControlSet\Services\NTDS\Diagnostics /v "6 Garbage↵
Collection" /t REG_DWORD /d 1
Using Windows PowerShell
$strRegPath = "HKLM:\System\CurrentControlSet\Services\NTDS\Parameters"
Set-ItemProperty -Path $strRegPath -Name "6 Garbage Collection" -value "1"
Discussion
By setting the 6 Garbage Collection diagnostics logging option, event 1646 will get
generated after the garbage collection process runs. Here is a sample 1646 event:
Event Type: Information
Event Source: NTDS Database
Event Category: Garbage Collection
Event ID: 1646
Date: 11/25/2012
Time: 9:52:46 AM
User: NT AUTHORITY\ANONYMOUS LOGON
Computer: DC1
Description:
Internal event: The Active Directory database has the following amount of↵
free hard disk space remaining.
596 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
622
|
Free hard disk space (megabytes): 100
Total allocated hard disk space (megabytes): 1024
This shows that domain controller Dc1 has a 1 GB DIT file with 100 MB that is free (i.e.,
whitespace).
See Also
Recipe 16.17 for performing an offline defrag
16.17. Performing an Offline Defrag to Reclaim Space
Problem
You want to perform an offline defrag of the Active Directory DIT to reclaim whitespace
in the DIT file.
Solution
Using a command-line interface
This recipe can be performed while the Active Directory Domain Services service is in
a stopped state; it is not necessary to reboot the DC into DSRM.
1. Once the AD DS service is stopped, check the integrity of the DIT as outlined in
Recipe 16.10.
2. Now, you are ready to perform the defrag operation. Run the following command
to create a compacted copy of the DIT file. You should check to make sure the drive
on which you create the copy has plenty of space. A rule of thumb is that it should
have at least 115 percent of the size of the current DIT available:
> ntdsutil "activate instance ntds" files "compact to <TempDriveAndFolder>"↵
q q
3. Delete the transaction logfiles in the current NTDS directory:
> del <CurrentDriveAndFolder>\*.log
4. You may want to keep a copy of the original DIT file for a short period of time to
ensure that nothing catastrophic happens to the compacted DIT. This does not
replace the need for a System State backup and a backup of the domain controller’s
system drive; it is simply a temporary measure to provide a fallback if the move
process itself goes wrong. If you are going to copy or move the original version, be
sure you have enough space in its new location:
> move <CurrentDriveAndFolder>\ntds.dit <TempDriveAndFolder>\ntds_orig.dit
> move <TempDriveAndFolder>\ntds.dit <CurrentDriveAndFolder>\ntds.dit
16.17. Performing an Offline Defrag to Reclaim Space | 597
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
623
|
5. Repeat the steps in Recipe 16.10 to ensure that the new DIT file is not corrupted.
If it is clean, reboot into normal mode and monitor the event log. If no errors are
reported in the event log, make sure the domain controller is backed up as soon as
possible.
Discussion
Performing an offline defragmentation of your domain controllers can reclaim disk
space if you’ve deleted a large number of objects from Active Directory. You should
perform an offline defrag when (and if) this occurs only if you actively require the disk
space back—for example, when following a spin-off in which you’ve migrated a large
number of objects into a separate domain. The database will reuse whitespace and grow
organically as required. Typically, the database grows year over year as more objects are
added, so an offline defrag should seldom be required. An offline defrag always carries
a small element of risk, so it should not be done unnecessarily.
The key thing to plan ahead of time is your disk space requirements. If you plan to create
the compacted copy of the DIT on the same drive as the current DIT, you need to make
sure that drive has 115 percent of the size of the DIT available. If you plan to store the
original DIT on the same drive, you’ll need to make sure you have at least that much
space available.
See Also
Recipe 16.10 for checking the integrity of the DIT; MS KB 198793 (The Active Directory
Database Garbage Collection Process); MS KB 229602 (Defragmentation of the Active
Directory Database); MS KB 232122 (Performing Offline Defragmentation of the Active
Directory Database)
16.18. Changing the Garbage Collection Interval
Problem
You want to change the default garbage collection interval.
Solution
Using a graphical user interface
1. Open ADSI Edit.
2. In the left pane, expand cn=Configuration→cn=Services→cn=Windows NT.
3. Right-click on cn=Directory Service and select Properties.
598 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
624
|
4. Edit the garbageColPeriod attribute and set it to the interval in hours that the
garbage collection process should run (the default is 12 hours).
5. Click OK.
Using a command-line interface
Create an LDIF file called change_garbage_period.ldf with the following contents:
dn: cn=Directory Service,cn=Windows NT,cn=Services,cn=Configuration,↵
<ForestRootDN>
changetype: modify
replace: garbageCollPeriod
garbageCollPeriod: <IntervalInHours>
-
Then run the following command:
> ldifde -v -i -f change_garbage_period.ldf
You can also modify the garbage collection period using AdMod:
> adfind -config -rb "cn=Directory Service,cn=Windows NT,cn=Services" -s base↵
-dsq | admod garbageCollPeriod::<IntervalInHours>
Using Windows PowerShell
Set-ADObject "cn=Directory Service,cn=Windows NT,cn=Services,cn=Configuration,↵
<ForestRootDN>" -Replace @{"garbageCollPeriod"="1"}
Discussion
In an environment where the Active Directory Recycle Bin is not enabled, when an
object is deleted from the Configuration naming context, a Domain naming context,
or an application partition, the object is tombstoned by renaming the object, moving it
to the Deleted Object container, and clearing the value of most of its attributes to save
space in the ntds.dit file. This tombstone object remains in Active Directory for the
duration of the tombstone lifetime (180 days for Windows Server 2012) before it gets
completely removed. See Recipe 16.24 for more information on the tombstone lifetime.
A garbage collection process runs on each domain controller that automatically removes
expired tombstone objects. This process runs every 12 hours by default, but you can
change it to run more or less frequently by setting the garbageCollPeriod attribute on
the following object to the frequency in hours:
"cn=Directory Service,cn=Windows NT,cn=Services,cn=Configuration,<RootDomainDN>"
16.18. Changing the Garbage Collection Interval | 599
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
625
|
See Also
Recipe 16.19 for logging the number of tombstones that get garbage-collected;
Recipe 16.24 for modifying the tombstone lifetime; MS KB 198793 (The Active Direc‐
tory Database Garbage Collection Process)
16.19. Logging the Number of Expired Tombstone Objects
Problem
You want to log the number of expired tombstone objects that are removed from Active
Directory during each garbage collection cycle.
Solution
Using a graphical user interface
1. Run regedit.exe from the command line or from Start→Run.
2. Expand HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS
\Diagnostics.
3. In the right pane, double-click on 6 Garbage Collection.
4. For Value data, enter 3.
5. Click OK.
Using a command-line interface
> reg add HKLM\System\CurrentControlSet\Services\NTDS\Diagnostics /v "6 Garbage↵
Collection" /t REG_DWORD /d 3
Using PowerShell
$strRegPath = "HKLM:\System\CurrentControlSet\Services\NTDS\Parameters"
Set-ItemProperty -Path $strRegPath -Name "6 Garbage Collection" -value "3"
Discussion
Here is a sample event that is logged when the 6 Garbage Collection diagnostics logging
level is set to 3 or higher:
Event Type: Information
Event Source: NTDS General
Event Category: Garbage Collection
Event ID: 1006
Date: 11/24/2012
Time: 11:29:31 AM
600 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
626
|
User: NT AUTHORITY\ANONYMOUS LOGON
Computer: DC1
Description:
Internal event: Finished removing deleted objects that have expired (garbage
collection). Number of expired deleted objects that have been removed: 229.
See Also
Recipe 15.1 for more on diagnostics logging; Recipe 16.18 for more on the garbage
collection process
16.20. Determining the Size of the Active Directory
Database
Problem
You want to determine the size of the Active Directory database.
Solution
Using a command-line interface
This recipe can be performed while the Active Directory Domain Services service is in
a stopped state; it is not necessary to reboot the DC into DSRM. Once the service is
stopped, you can display file information using the following syntax:
> ntdsutil
> activate instance ntds
> files
> info
> quit
> quit
When you are finished, don’t forget to restart the AD DS service, as well as any dependent
services that halted when you stopped Active Directory Domain Services.
Discussion
The size of the Active Directory database on a domain controller is the size of the ntds.dit
file. This file can vary slightly in size between domain controllers, even within the same
domain, due to unreplicated changes, differences with nonreplicated data, and white‐
space from purged objects.
You should monitor the size of this file on one or more domain controllers in each of
your domains to ensure that you have adequate disk space. Also, by knowing the average
16.20. Determining the Size of the Active Directory Database | 601
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
627
|
size of your DIT, you can quickly recognize if it spikes dramatically, perhaps due to a
new application that is writing data to the directory.
If you find that you are running out of disk space, you have a couple of options. You
could move the Active Directory files to a new drive with more capacity. Alternatively,
you can perform an offline defragmentation if the DIT file contains a lot of whitespace.
See Also
Recipe 16.11 for moving the DIT files; Recipe 16.16 for determining how much white‐
space is in the DIT; Recipe 16.17 for performing an offline defragmentation of the Active
Directory database
16.21. Searching for Deleted Objects
Problem
You want to search for deleted objects.
Solution
Using a graphical user interface
1. Launch the Active Directory Administrative Center.
2. Select the domain and then navigate to the Deleted Objects container.
3. Use the filter search bar to search through the deleted objects.
Using a command-line interface
To view all of the deleted objects in the current domain, use the following syntax:
> adfind -default -rb "cn=Deleted Objects" -showdel
You can also use the adrestore.exe utility from the Microsoft website by simply typing
adrestore from the command line.
Using PowerShell
You view all of the deleted objects in the current domain, use the following PowerShell
command:
Get-ADObject -Filter {isDeleted -eq $True} -IncludeDeletedObjects |↵
FT Name,objectCLass
602 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
628
|
Discussion
When an object is deleted in Active Directory, it is not really deleted, at least not im‐
mediately. The object is renamed, most of its attributes are cleared, and it is moved to
the Deleted Objects container within the naming context that it was deleted from. See
this chapter’s Recipe 16.0 for more on tombstone objects.
Not all objects are moved to the Deleted Objects container. If you are
unable to find a given deleted object, open the search scope to the whole
naming context the object previously existed in.
Both the Deleted Objects container and tombstone objects themselves are hidden by
default in tools such as ADUC and ADSI Edit. Only members of the administrator
groups can perform searches for tombstone objects.
See Also
MSDN: Retrieving Deleted Objects
16.22. Undeleting a Single Object
Problem
You want to undelete an object that has been deleted from your Active Directory do‐
main. This recipe assumes that the Active Directory Recycle Bin has been enabled. If
you have not enabled the AD Recycle Bin, you can do so from the Tasks pane in the
Active Directory Administrative Center.
Solution
Using a graphical user interface
1. Launch the AD Administrative Center.
2. Select the domain and navigate to the Deleted Objects container.
3. Locate the deleted object in the container.
4. Right-click the object and select Restore.
16.22. Undeleting a Single Object | 603
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
629
|
Using Windows PowerShell
To restore all deleted user objects, run the following PowerShell command:
Get-ADObject -Filter {(isDeleted -eq $true) -and (ObjectClass -eq "user") -and↵
(ObjectClass -ne "computer")} -IncludeDeletedObjects | Restore-ADObject
The filter option can be expanded to reduce the number of objects returned, or to return
only specific objects.
Discussion
Another option when restoring a single object is to perform a System State restore on
a domain controller, and then to use ntdsutil to mark the individual object as authori‐
tative. This has the downside of causing downtime on a domain controller, since you’ll
need to reboot it into Directory Services Repair Mode to perform the restore.
Microsoft also offers the adrestore command-line utility that will enumerate the deleted
objects in a domain and give you the option to undelete them.
See Also
“Step 2: Restore a Deleted Active Directory Object”; the other recipes in this chapter for
more on AD backups, restores, snapshots, and disaster recovery
16.23. Undeleting a Container Object
Problem
You want to undelete a container object such as an OU that contained other objects
when it was deleted.
Solution
Using a graphical user interface
Use the steps in Recipe 16.22 to first undelete the container object. Then undelete each
individual child object that was contained within the container, specifying the contain‐
er’s DN in the restored object’s DN. Alternately, perform a System State restore and use
ntdsutil to mark the restored OU as authoritative, as described in Recipe 16.8.
604 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
630
|
Performing an authoritative restore of user or group objects will require
additional considerations, as detailed in MS KB 280079 (Authoritative
Restore of Groups Can Result in Inconsistent Membership Information
Across Domain Controllers).
Using a command-line interface
> adfind -default -rb "cn=Deleted Objects" -f "(name=<ContainerRDN>*)"↵
-showdel -dsq | admod -undel
> adfind -default -rb "cn=Deleted Objects" -f↵
("lastKnownParent=<ParentContainerDN>") -showdel -dsq | admod -undel
Using Windows PowerShell
To restore all child objects of an organizational unit named Accounts, use the following
command:
Get-ADObject -Filter {(isDeleted -eq $True) -and (lastKnownParent -eq↵
"ou=Accounts,dc=adatum,dc=com")} -IncludeDeletedObjects | Restore-ADObject
Discussion
When you delete an Active Directory container object, it also deletes any child objects
that are housed within that container. Restoring an OU and all of the child objects, for
example, therefore requires you to restore both the container itself as well as all of the
child objects contained within it. This is relatively simple to perform using Windows
PowerShell since you can restrict your query to those objects that have the appropriate
value listed in the lastKnownParent attribute.
See Also
MSDN: Restoring Deleted Object [Active Directory]
16.24. Modifying the Tombstone Lifetime for a Domain
Problem
You want to change the default tombstone lifetime for a domain.
Solution
Using a graphical user interface
1. Open ADSI Edit.
2. In the left pane, expand cn=Configuration→cn=Services→cn=Windows NT.
16.24. Modifying the Tombstone Lifetime for a Domain | 605
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
631
|
3. Right-click on cn=Directory Service and select Properties.
4. Set the tombstoneLifetime attribute to the number of days that tombstone objects
should remain in Active Directory before getting removed completely.
5. Click OK.
Using a command-line interface
Create an LDIF file called change_tombstone_lifetime.ldf with the following contents:
dn: cn=Directory Service,cn=Windows NT,cn=Services,cn=Configuration,↵
<ForestRootDN>
changetype: modify
replace: tombstoneLifetime
tombstoneLifetime: <NumberOfDays>
-
Then run the following command:
> ldifde -v -i -f change_tombstone_lifetime.ldf
You can also make this change using AdMod, as follows:
> admod -b "cn=Directory Service,cn=WindowsNT,↵
cn=Services,cn=Configuration,<ForestRootDN>" tombstoneLifetime::<NumberOfDays>
Using PowerShell
Set-ADObject "cn=Directory Service,cn=Windows NT,cn=Services,cn=Configuration,↵
<ForestRootDN>" -Replace @{"tombstoneLifetime"="<NumberOfDays>"}
Discussion
The default tombstone lifetime for Windows 2008 and later is set to 180 days. It is not
recommended that you decrease the tombstone lifetime unless you have a very good
reason for doing so, since decreasing this value below the 180-day default also decreases
the length of time a backup of Active Directory is good for. See this chapter’s Recipe 16.0
and Recipe 16.21 for more information on tombstone (deleted) objects and the tomb‐
stone lifetime.
See Also
Recipe 16.18 for more on the garbage collection process; MS KB 198793 (The Active
Directory Database Garbage Collection Process); MS KB 314282 (Lingering Objects
May Remain After You Bring an Out-of-Date Global Catalog Server Back Online)
606 | Chapter 16: Backup, Recovery, DIT Maintenance, and Deleted Objects
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
632
|
CHAPTER 17
Application Partitions
17.0. Introduction
Active Directory domain controllers, when first installed, host three predefined parti‐
tions. The Configuration naming context is replicated to all domain controllers in the
forest, and it contains information that is needed forest-wide, such as the site topology
and LDAP query policies. The Schema naming context is also replicated forest-wide and
contains all of the schema objects that define how data is stored and structured in Active
Directory. The third partition is the Domain naming context, which is replicated to all
of the domain controllers that host a particular domain.
There is another partition type that is called an application partition, which is very
similar to the other naming contexts except that you can configure which domain con‐
trollers in the forest will replicate the data that’s contained within it. Examples include
the DomainDnsZones partition, which is replicated across all AD integrated DNS servers
in the same domain, and ForestDnsZones, which is replicated across all AD integrated
DNS servers in the forest. This capability gives administrators much more flexibility
over how they can store and replicate the data that is contained in Active Directory. If
you need to replicate a certain set of data to only two different sites, for example, you
can create an application partition that will only replicate the data to the domain con‐
trollers in those two sites rather than replicating the data to additional DCs that have
no need for it.
See Chapter 13 for more on DNS-related management tasks, as well as Active Directo‐
ry, Fifth Edition, by Brian Desmond et al. (O’Reilly), for more details on application
partitions.
The Anatomy of an Application Partition
Application partitions are stored in Active Directory in a similar fashion as a Domain
NC. In fact, application partitions and Domain NCs consist of the same two types of
607
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
633
|
objects: a domainDNS object and a crossRef object that resides under the Partitions
container in the Configuration naming context (CNC). Application partitions have a
similar naming convention as domains and can be named virtually anything you want.
You can create an application partition that uses the current namespace within the forest.
For example, in the adatum.com (dc=adatum,dc=com) forest, you could create an
apps.adatum.com (dc=apps,dc=adatum,dc=com) application partition. Alternatively, a
name that is part of a new tree can also be used; for example, apps.local (dc=apps,dc=lo
cal). Application partitions can also be subordinate to other application partitions.
Table 17-1 and Table 17-2 contain some of the interesting attributes of domainDNS and
crossRef objects as they apply to application partitions.
Table 17-1. Attributes of domainDNS objects
Attribute Description
dc Relative distinguished name of the application partition.
instanceType This attribute must be set to 5 when creating an application partition. See Recipe 17.1 for more information.
msDs-masteredBy List of nTDSDSA object DNs of the domain controllers that replicate the application partition. See
Recipe 17.4 for more information.
Table 17-2. Attributes of crossRef objects
Attribute Description
cn Relative distinguished name of the crossRef object. This value is generally a GUID for
application partitions.
dnsRoot Fully qualified DNS name of the application partition.
msDS-NC-ReplicaLocations
List of nTDSDSA object DNs of the domain controllers that replicate the application partition.
See Recipe 17.4 for more information.
msDSSDReferenceDomain
Domain used for security descriptor translation. See Recipe 17.8 for more information.
nCName Distinguished name of the application partition’s corresponding domainDNS object.
systemFlags Bit flag that identifies whether the crossRef represents an application. See Recipe 17.2 for
more information.
17.1. Creating and Deleting an Application Partition
Problem
You want to create or delete an application partition. Application partitions are useful
if you need to replicate data to a subset of locations where you have domain controllers.
Instead of replicating the application data to all domain controllers in a domain, you
can use an application partition to replicate the data to only the domain controllers of
your choosing.
608 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
634
|
Solution
Using a command-line interface
Use the following command to create an application partition on a domain controller:
> ntdsutil
> activate instance ntds
> partition management
> connections
> connect to server <DomainControllerName>
> quit
> create nc <AppPartitionDN> NULL
> quit
> quit
Use the following command to delete an application partition:
> ntdsutil
> activate instance ntds
> partition management
> connections
> connect to server <DomainControllerName>
> quit
> delete nc <AppPartitionDN>
> quit
> quit
Discussion
To create an application partition, you create a domainDNS object that serves as the root
container for the partition. A crossRef object is automatically created in the Parti
tions container in the Configuration NC. Conversely, when removing an application
partition, you only need to remove the crossRef object and the domainDNS is automat‐
ically deleted. When you delete an application partition, all objects within the partition
also get deleted. Tombstone objects are not created for any of the objects within the
application partition or for the application partition itself.
See Also
MSDN: Creating an Application Directory Partition; MSDN: Deleting an Application
Directory Partition
17.2. Finding the Application Partitions in a Forest
Problem
You want to find the application partitions that have been created in a forest.
17.2. Finding the Application Partitions in a Forest | 609
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
635
|
Solution
Using a graphical user interface
1. Open LDP.
2. From the menu, select Connection→Connect.
3. Click OK to connect to the closest domain controller over port 389.
4. From the menu, select Connection→Bind.
5. Click OK to bind as the currently logged on user or select the option to bind with
credentials, enter the credentials, and then click OK.
6. From the menu, select Browse→Search.
7. For Base DN, type the DN of the Partitions container (e.g., cn=parti
tions,cn=configuration,dc=adatum,dc=com).
8. For Filter, enter:
(&(objectcategory=crossRef)(systemFlags:1.2.840.113556.1.4.803:=5))
9. For Scope, select One Level.
10. Click the Options button.
11. For Attributes, enter dnsRoot.
12. Click Run.
Using a command-line interface
Use the following command to find all of the application partitions in a forest:
> dsquery * cn=partitions,cn=configuration,<ForestDN> -filter↵
"(&(objectcategory=crossRef)(systemFlags:1.2.840.113556.1.4.803:=5))"↵
-scope onelevel -attr dnsRoot
You can also find application partitions in a forest using AdFind:
> adfind -sc appparts+
Using PowerShell
The following example will search for application partitions within an Active Directory
domain:
Get-ADObject -SearchBase "cn=partitions,cn=configuration,<ForestDN>" -Filter↵
{(objectCategory -eq "crossref") -and (systemFlags -eq "5")}
610 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
636
|
Discussion
To get the list of application partitions in this recipe’s solution, we queried all cross
Ref objects in the Partitions container that have the systemFlags attribute with the
bits 0 and 2 set (5 in decimal). To do this, a logical AND bitwise filter was used. See
Recipe 4.12 for more on searching with a bitwise filter.
You can take a shortcut by not including the bitwise OID in the search filter, and chang‐
ing it to systemFlags=5. This currently produces the same results in the test forest as
with the bitwise filter, but there are no guarantees since it is a bit-flag attribute. You may
encounter circumstances in which an application partition would have another bit set
in systemFlags that would yield a different value.
In each solution, the dnsRoot attribute was printed for each application partition, which
contains the DNS name of the application partition. You can also retrieve the nCName
attribute, which contains the distinguished name of the application partition.
See Also
Recipe 4.12
17.3. Adding or Removing a Replica Server for an
Application Partition
Problem
You want to add or remove a replica server for an application partition. After you’ve
created an application partition, you should make at least one other server a replica
server in case the first server fails.
Solution
Using a graphical user interface
To add a replica server to an application partition, follow these steps:
1. Open ADSI Edit.
2. If necessary, connect to the Configuration naming context of the forest the appli‐
cation partition is in.
3. Expand the Configuration naming context and click on cn=Partitions.
4. In the right pane, right-click on the crossRef object that represents the application
partition and select Properties.
5. Under Attributes, select the msDS-NC-Replica-Locations attribute and click Edit.
17.3. Adding or Removing a Replica Server for an Application Partition | 611
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
637
|
6. In the “Value to add” field, enter the following:
cn=NTDS Settings,cn=<DCName>,cn=Servers,cn=Default-First-Site-Name,↵
cn=Sites,cn=Configuration,<ForestDN>
7. Click Add, and then OK twice.
To remove a replica server from an application partition, follow these steps:
1. Open ADSI Edit.
2. If necessary, connect to the Configuration naming context of the forest the appli‐
cation partition is in.
3. Expand the Configuration naming context and click on cn=Partitions.
4. In the right pane, right-click on the crossRef object that represents the application
partition and select Properties.
5. Under Attributes, select the msDS-NC-Replica-Locations attribute and click Edit.
6. Select the value to remove and then click Remove.
7. Click OK twice.
Using a command-line interface
Use the following command to add a replica server for an application partition:
> ntdsutil
> activate instance ntds
> partition management
> connections
> connect to server <DomainControllerName>
> quit
> add nc replica<AppPartitionDN> <DomainControllerName>
> quit
> quit
Use the following command to remove a replica server from an application partition:
> ntdsutil
> activate instance ntds
> partition management
> connections
> connect to server <DomainControllerName>
> quit
> remove nc replica <AppPartitionDN> <DomainControllerName>
> quit
> quit
612 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
638
|
Using PowerShell
The following command will add DC2 to the list of replica locations for app1.ada‐
tum.com, while leaving the rest of the list intact:
Get-ADObject -SearchBase "cn=Partitions,cn=Configuration,dc=adatum,dc=com"↵
-Filter {dnsroot -eq "app1.adatum.com"} | Set-ADObject↵
-Add @{"msDS-NC-Replica-Locations"="cn=NTDS Settings,cn=DC2,cn=Servers, ↵
cn=Default-First-Site-Name,cn=Sites,cn=Configuration,dc=adatum,dc=com"}
The following command will remove DC2 from the replica location list for app1.ada‐
tum.com, without removing any other entries:
Get-ADObject -SearchBase "cn=Partitions,cn=Configuration,dc=adatum,dc=com"↵
-Filter {dnsroot -eq "app1.adatum.com"} | Set-ADObject↵
-Remove @{"msDS-NC-Replica-Locations"="cn=NTDS Settings,cn=DC2,cn=Servers,↵
cn=Default-First-Site-Name,cn=Sites,cn=Configuration,dc=adatum,dc=com"}
Discussion
When you initially create an application partition, there is only one domain controller
that hosts the application partition, namely the one you created the application partition
on. You can add any other domain controllers in the forest as replica servers. The list
of replica servers is stored in the msDS-NC-Replica-Locations attribute on the cross
Ref object for the application partition in the Partitions container. That attribute
contains the distinguished name of each replica server’s nTDSDSA object. To add a replica
server, simply add the DN of the new replica server’s nTDSDSA object. To remove a replica
server, remove the DN corresponding to the server’s nTDSDSA object that you want to
remove. Behind the scenes, the KCC gets triggered anytime there is a change to that
attribute, at which point it will either cause the application partition to get replicated to
the target domain controller or remove the replica from the target DC. When a domain
controller is demoted, it should automatically remove itself as a replica server for any
application partitions that it replicated.
See Also
Recipe 17.4 for finding the replica servers for an application partition
17.4. Finding the Replica Servers for an Application
Partition
Problem
You want to find the replica servers for an application partition.
17.4. Finding the Replica Servers for an Application Partition | 613
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
639
|
Solution
Using a graphical user interface
1. Open ADSI Edit.
2. Connect to the Configuration naming context of the forest the application partition
is in, if it is not already present in the left pane.
3. Expand the Configuration naming context and click on the Partitions container.
4. In the right pane, right-click on the crossRef object that represents the application
partition and select Properties.
5. Under Attributes, select the msDS-NC-Replica-Locations attribute and then click
View.
Using a command-line interface
> ntdsutil
> activate instance ntds
> partition management
> connections
> connect to server <DomainControllerName>
> quit
> list nc replicas <AppPartitionDN>
> quit
> quit
Using PowerShell
Get-ADObject -SearchBase "cn=Partitions,cn=Configuration,dc=adatum,dc=com"↵
-Filter; {dnsroot -eq "<PartitionFQDN>"} -Properties msDS-NC-Replica-Locations
Discussion
The list of replica servers for an application partition is stored in the multivalued msDSNC-Replica-Locations attribute on the crossRef object for the application partition.
This object is located in the Partitions container in the Configuration naming context.
See Also
Recipe 17.3 for adding and removing replica servers
614 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
640
|
17.5. Finding the Application Partitions Hosted
by a Server
Problem
You want to find the application partitions that a particular server is hosting. Before you
decommission a server, it is good to check to see whether it hosts any application par‐
titions and, if so, to add another replica server to replace it.
Solution
Using a graphical user interface
1. Open LDP.
2. From the menu, select Connection→Connect.
3. Click OK to connect to the closest domain controller over port 389.
4. From the menu, select Connection→Bind.
5. Click OK to bind as the currently logged on user or select the option to bind with
credentials, enter the credentials, and then click OK.
6. From the menu, select Browse→Search.
7. For Base DN, type the DN of the Partitions container (e.g., cn=parti
tions,cn=configuration,dc=adatum,dc=com).
8. For Filter, enter:
(&(objectcategory=crossRef)(systemFlags:1.2.840.113556.1.4.803:=5)↵
(msDS-NC-Replica-Locations=cn=NTDS Settings,cn=<DomainControllerName>,↵
cn=servers,cn=<SiteName>,cn=sites,cn=configuration,<ForestDN>))
9. For Scope, select One Level.
10. Click the Options button.
11. For Attributes, enter dnsRoot.
12. Click OK.
13. Click Run.
Using a command-line interface
Use the following command to find all of the application partitions hosted by a domain
controller. To run this command, you need the distinguished name of the forest root
domain (<ForestDN>), the common name of the DC’s server object (<DomainControl
lerName>), and the common name of the site object the server is in (<SiteName>).
17.5. Finding the Application Partitions Hosted by a Server | 615
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
641
|
> dsquery * "cn=partitions,cn=configuration,<ForestDN>" -scope onelevel -attr↵
dnsRoot -filter "(&(objectcategory=crossRef)↵
(systemFlags:1.2.840.113556.1.4.803:=5)
(msDS-NC-Replica-Locations=cn=NTDS Settings,cn=<DomainControllerName>,↵
cn=servers,cn=<SiteName>,cn=sites,cn=configuration,<ForestDN>))"
You can also display the application partitions hosted by a particular DC using AdFind:
> adfind -partitions -s onelevel -bit -f↵
"(&(objectcategory=crossRef)(systemFlags:AND:=5)↵
(msDS-NC-Replica-Locations=cn=NTDS
Settings,cn=<DomainControllerName>,cn=servers,cn=<SiteName>,↵
cn=sites,cn=configuration,<ForestRootDN>))"
Using PowerShell
Get-ADObject -SearchBase "cn=Partitions,cn=Configuration,dc=adatum,dc=com"↵
-Filter {(objectCategory -eq "crossRef") -and (systemFlags -eq "5") -and↵
(msDS-NC-Replica-Locations -eq "cn=NTDS Settings,cn=<DCName>,cn=servers,↵
cn=<SiteName>,cn=sites,cn=configuration,<ForestDN>")}
Discussion
As described in Recipe 17.3 and Recipe 17.4, the msDS-NC-Replica-Locations attribute
on crossRef objects contains the list of replica servers for a given application partition.
Each of the solutions illustrates how to perform a query using this attribute to locate all
of the application partitions a particular domain controller is a replica server for. For
the GUI and CLI solutions, you need to know the distinguished name of the nTDSDSA
object for the target domain controller.
See Also
Recipe 17.3 and Recipe 17.4 for finding the replica servers for an application partition
17.6. Verifying Application Partitions Are Instantiated
Correctly on a Server
Problem
You want to verify that an application partition is instantiated on a replica server. After
you add a domain controller as a replica server for an application partition, the data in
the application partition needs to fully replicate to that domain controller before it can
be used on that domain controller.
616 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
642
|
Solution
Using a command-line interface
Use the following command to determine whether there are any problems with appli‐
cation partitions on a domain controller:
> dcdiag /test:checksdrefdom /test:verifyreplicas /test:crossrefvalidation↵
/s:<DomainControllerName>
You can also verify the state of a particular application partition by using ntdsutil as
follows:
> ntdsutil
> activate instance ntds
> partition management
> connections
> connect to server <DCName>
> quit
> list nc replicas <PartitionDN>
> quit
> quit
Discussion
The dcdiag CheckSDRefDom, VerifyReplicas, and CrossRefValidation tests can help
determine whether an application partition has been instantiated on a server and
whether there are any problems with it. Here is the dcdiag help information for those
three tests:
CrossRefValidation
This test looks for cross-references that are in some way invalid.
CheckSDRefDom
This test checks that all application directory partitions have appropriate security
descriptor reference domains.
VerifyReplicas
This test verifies that all application directory partitions are fully instantiated on all
replica servers.
Another way you can check to see whether a certain application partition has been
instantiated on a domain controller is to look at the msDS-HasInstantiatedNCs attribute
for the server’s nTDSDSA object. That attribute has DN with Binary syntax and contains
a list of all the application partitions that have been successfully instantiated on the
server. Unfortunately, tools such as ADSI Edit and DSQuery do not interpret DN with
Binary attributes correctly, but it can be viewed with LDP. In addition, you can use
AdFind as follows:
17.6. Verifying Application Partitions Are Instantiated Correctly on a Server | 617
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
643
|
adfind -b "cn=NTDS Settings,cn=<DCName>,cn=Servers,cn=<SiteName>,cn=Sites,↵
cn=Configuration,<ForestDN>" -f↵
"msds-HasInstantiatedNCs=B:8:0000000D:<ParitionDN>" -dn
This will return results similar to the following:
AdFind V01.47.00cpp Joe Richards (joe@joeware.net) October 2012
Using server: adatum-dc.adatum.com:389
Directory: Windows Server 2012
dn:cn=NTDS Settings,cn=DC2,cn=Servers,cn=Default-First-Site-Name,cn=Sites
cn=Configuration,dc=adatum,dc=com
1 Objects returned
See Also
MSDN: ms-DS-Has-Instantiated-NCs attribute [AD Schema]
17.7. Setting the Replication Notification Delay for an
Application Partition
Problem
You want to set the replication notification delay for an application partition. Two
replication-related settings that you can customize for application partitions (or any
naming context for which change notification is enabled) include the first and subse‐
quent replication delays after a change to the partition has been detected. The first
replication delay is the time that a domain controller waits before it notifies its first
replication partner that there has been a change. The subsequent replication delay is the
time that the domain controller waits after it has notified its first replication partner
before it will notify its next partner. You may need to customize these settings so that
replication happens as quickly as you need it to for data in the application partition.
Solution
Using a graphical user interface
1. Open ADSI Edit.
2. Connect to the Configuration naming context of the forest that the application
partition is in if a connection is not already present in the left pane.
3. Expand the Configuration naming context and click on the Partitions container.
4. In the right pane, right-click on the crossRef object that represents the application
partition and select Properties.
618 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
644
|
5. Set the msDS-Replication-Notify-First-DSA-Delay and msDS-ReplicationNotify-Subsequent-DSA-Delay attributes to the number of seconds you want for
each delay (see this recipe’s “Discussion” for more details).
6. Click OK.
Using a command-line interface
To change the settings using the command line, run the following command:
> repadmin /notifyopt "<DCName>" "<AppPartitionDN>"↵
/first:<FirstDelayInSeconds>
/subs:<NextDelayInSeconds>
You can also change both of these parameters using AdMod, as follows:
> admod -b <AppPartitionCrossRefDN>↵
msDS-Replication-Notify-First-DSA-Delay::<FirstDelayInSeconds>↵
msDS-Replication-Notify-Subsequent-DSA-Delay::<NextDelayInSeconds>
Using PowerShell
To modify the initial and subsequent notification delays, you can use the following
PowerShell commands:
Set-ADObject "<PartitionDN>" -Replace↵
@{"msDS-Replication-Notify-First-DSA-Delay"="<Interval>"}
Set-ADObject "<PartitionDN>" -Replace↵
@{"msDS-Replication-Notify-Subsequent-DSA-Delay"="<Interval>"}
Discussion
The settings that control the notification delay are stored in the msDS-ReplicationNotify-First-DSA-Delay and msDS-Replication-Notify-Subsequent-DSA-Delay
attributes on the application partition’s crossRef object in the Partitions container.
The time values are stored as seconds. The default for application partitions is 15 seconds
for the first delay and three seconds for each subsequent delay.
See Also
MSDN: Application Directory Partition Replication [Active Directory]; MSDN: Mod‐
ifying Application Directory Partition Configuration [Active Directory]; MSDN: msDS-Replication-Notify-First-DSA-Delay; MSDN: ms-DS-Replication-NotifySubsequent-DSA-Delay
17.7. Setting the Replication Notification Delay for an Application Partition | 619
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
645
|
17.8. Setting the Reference Domain for an
Application Partition
Problem
You want to set the reference domain for an application partition. Whenever you create
an object in Active Directory, the default security descriptor that’s defined in the schema
for the object’s class is applied to the object. This default security descriptor may refer‐
ence specific groups, such as Domain Admins, but it is not specific to a domain. This
makes a lot of sense for domain naming contexts, where the Domain Admins group in
question would be the one that’s defined in the domain in question. But for application
partitions that don’t contain a Domain Admins group, it is not so straightforward. Which
domain’s Domain Admins group do you use? To work around this issue, you can set a
default security descriptor reference domain for an application partition by setting the
msDS-SDReferenceDomain attribute of the partition’s crossRef object. The default value
of the msDS-SDReferenceDomain attribute is the domain that the application partition
was created in.
Solution
Using a graphical user interface
1. Open ADSI Edit.
2. Connect to the Configuration naming context of the forest the application partition
is in if it is not already present in the left pane.
3. Expand the Configuration naming context and click on the Partitions container.
4. In the right pane, right-click on the crossRef object that represents the application
partition and select Properties.
5. Under Attributes, select the msDS-SDReferenceDomain attribute.
6. Enter the Distinguished Name for the appropriate domain and click OK.
Using a command-line interface
> ntdsutil
> activate instance ntds
> partition management
> connections
> connect to server <DomainControllerName>
> quit
> set nc ref domain<AppPartitionDN> <DomainDN>
> quit
> quit
620 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
646
|
You can also set the reference domain using AdMod:
> adfind -partitions -f "(dnsRoot=<PartitionDNSName>)" -dsq |↵
admod msDS-SDReferenceDomain::"<DomainDN>"
Using PowerShell
Set-ADObject "<PartitionDN>" -Replace @{"msDS-SDReferenceDomain"="<DomainDN>"}
Discussion
If you don’t set the msDS-SDReferenceDomain attribute for an application partition, then
a specific hierarchy will be followed to determine the default security descriptor domain.
These are the guidelines:
• If the application partition is created as part of a new tree, the forest root domain
is used as the default domain.
• If the application partition is a child of a domain, the parent domain is used as the
default domain.
• If the application partition is a child of another application partition, the parent
application partition’s default domain is used.
See Also
Recipe 10.18 for more on setting the default security descriptor for a class; Recipe 17.1
for creating an application partition
17.9. Delegating Control of Managing an
Application Partition
Problem
You want to delegate control over the management of an application partition.
Solution
Using a graphical user interface
1. Open ADSI Edit.
2. Connect to the Configuration naming context of the forest the application partition
is in if it is not already present in the left pane.
3. Expand the Configuration naming context and click on the Partitions container.
17.9. Delegating Control of Managing an Application Partition | 621
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
647
|
4. In the right pane, right-click on the crossRef object that represents the application
partition and select Properties.
5. Click the Security tab.
6. Click the Advanced button.
7. Click the Add button.
8. Use the object picker to find the user or group you want to delegate control to and
click OK.
9. Under Properties, check the boxes beside Write msDS-NC-Replica-Locations,
Write msDS-SDReferenceDomain, Write msDS-Replication-Notify-First-DSADelay, and Write msDS-Replication-Notify-Subsequent-DSA-Delay.
10. Click OK.
Using a command-line interface
> dsacls <AppPartitionCrossRefDN> /G <UserOrGroup>:RPWP;msDS-NC-Replica-Locations
> dsacls <AppPartitionCrossRefDN> /G <UserOrGroup>:RPWP;msDS-SDReferenceDomain
> dsacls <AppPartitionCrossRefDN> /G <UserOrGroup>:RPWP;msDS-Replication-↵
Notify-First-DSA-Delay
> dsacls <AppPartitionCrossRefDN> /G <UserOrGroup>:RPWP;msDS-Replication-↵
Notify-Subsequent-DSA-Delay
As is the case with most permissions, you should exercise care when
delegating the ability to create or modify application partitions. Because
application partitions reside within Active Directory, allowing them to
be placed indiscriminately or setting the initial and subsequent repli‐
cation delays too low can bring your network to a grinding halt.
Discussion
If you want to delegate control of management of application partitions, you must grant
control over four key attributes. Here is a description of each attribute and what can be
accomplished by having control over it:
msDS-NC-Replica-Locations
A user can add replica servers for the application partition. See Recipe 17.3 for more
information.
msDS-SDReferenceDomain
A user can define the default security descriptor domain for the application parti‐
tion. See Recipe 17.8 for more information.
msDS-Replication-Notify-First-DSA-Delay
See Recipe 17.7 for more information.
622 | Chapter 17: Application Partitions
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
648
|
msDS-Replication-Notify-Subsequent-DSA-Delay
See Recipe 17.7 for more information.
If you want to delegate control over managing objects within the application partition,
you need to follow the same procedures you would when delegating control over objects
in a domain naming context. See Recipe 13.9 for more information on delegating
control.
See Also
Recipe 13.9; Recipe 14.5 for delegating control; Recipe 17.3 for more on adding and
removing replica servers; Recipe 17.7 for more on the replication delay attributes;
Recipe 17.8 for more on the default security descriptor domain
17.9. Delegating Control of Managing an Application Partition | 623
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
649
| null |
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
650
|
CHAPTER 18
Active Directory Lightweight
Directory Service
18.0. Introduction
Active Directory Application Mode (ADAM) was released in November 2003 on the
Microsoft website. With the release of Windows Server 2008, along with several other
technologies, Microsoft renamed ADAM. The new name for ADAM is Active Directory
Lightweight Directory Service (AD LDS). AD LDS is a lightweight LDAP platform that
allows developers and administrators to work with AD objects such as users, groups,
and organizational units, without worrying about the overhead of running a full-blown
copy of the Active Directory Domain Services. AD LDS can run on Windows Server
2012 and Windows 8 computers, and you can run multiple instances of AD LDS on a
single machine. Because AD LDS runs as a standalone service, you can start, stop, install,
or remove AD LDS instances without affecting or interfering with any underlying AD
infrastructure. AD LDS can leverage domain authentication, local machine users, and
groups, or it can authenticate users based on security principals that you’ve created
within AD LDS itself. (It’s important to note that these are separate from Active Direc‐
tory security principals, which cannot be created within an AD LDS instance.)
AD LDS includes the following features:
Server Core support
AD LDS can be installed on computers that are running Server Core, the reducedfootprint installation option that was introduced with Windows Server 2008.
Auditing for AD LDS changes
The Directory Services Changes audit policy subcategory allows you to view old
and new values when changes are made to AD LDS objects.
625
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
651
|
Database Mounting Tool (Dsamain.exe)
Similar to Active Directory Domain Services, you can use dsamain to mount snap‐
shots of AD LDS partitions to view and compare information from previous points
in time.
Support for Active Directory Sites and Services
You can now use the AD Sites and Services MMC to manage replication between
AD LDS instances.
18.1. Installing AD LDS
Problem
You want to install a new instance of AD LDS.
Solution
Using a graphical user interface
To install AD LDS on a Windows Server 2012 server, do the following:
1. Launch Server Manager.
2. Click Manage and then click Add Roles and Features.
3. Click Next three times.
4. Place a checkmark next to Active Directory Lightweight Directory Services.
5. Click Add Features and then click Next three times.
6. Click Install.
Using Windows PowerShell
To perform a Windows PowerShell install of AD LDS on Windows Server 2012, run the
following command:
Install-WindowsFeature -Name "ADLDS" -IncludeAllSubFeature↵
-IncludeManagementTools
Discussion
At its most basic level, an AD LDS installation will simply copy the necessary program
files and DLLs to the machine in question without creating an AD LDS instance or
performing any other configuration steps. This can be useful if you want to include AD
LDS as part of a base image that you deploy to your application developers, while al‐
lowing them to create their own instances and configuration sets as they see fit.
626 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
652
|
If the installation process encounters any errors, these will be logged in
the %windir%\Debug\adamsetup.log file.
See Also
Recipe 18.2; Recipe 18.3
18.2. Creating a New AD LDS Instance
Problem
You want to create a new AD LDS instance.
Solution
Using a graphical user interface
1. From Administrative Tools, launch the Active Directory Lightweight Directory
Services Setup Wizard and then click Next.
2. Select the radio button next to “A unique instance” and click Next.
3. Enter the name of the instance and click Next.
4. Enter the LDAP and SSL port numbers that will be used to access this instance;
these default to 50000 and 50001 on a domain controller or any computer that is
already listening on the default LDAP port. Otherwise, the LDAP and SSL ports
that AD LDS chooses during the installation will be 389 and 636.
If you’ve already installed an AD LDS instance on ports 50000 and
50001, the AD LDS installer will choose the next two ports avail‐
able; the second AD LDS instance would choose ports 50002 and
50003, then 50004 and 50005, and so on.
5. Click Next to continue.
6. Specify whether you want to create an Application Directory partition for this in‐
stance. You can use any partition name that isn’t already being used, such as cn=In
tranetApplication,dc=adatum,dc=com. Click Next to continue.
7. Specify the directory that will house the instance data as well as its data recovery
files. These will both default to c:\Program Files\Microsoft ADAM\<instance name>
\data. Click Next.
18.2. Creating a New AD LDS Instance | 627
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
653
|
8. On the Service Account Selection screen, configure the account under whose se‐
curity context this instance will run. By default, Network Service Account is se‐
lected, or you can click the radio button next to “This account” and specify a dif‐
ferent account.
9. On the AD LDS administrator’s screen, specify the user or group account that will
have administrative rights to this AD LDS instance. This defaults to the currently
logged-on user, or you can click the radio button next to “This account” and specify
a different user or group. Click Next.
10. Specify whether you want to import additional LDIF files into this instance. See
Recipe 18.7 for more information.
11. Click Next twice and then click Finish to create the new instance.
Using a command-line interface
Create an answer file similar to the one listed here. Save it as adlds_install.txt:
[ADAMInstall]
Install a unique AD LDS instance
InstallType=Unique
Specify the name of the new instance
InstanceName=IntranetApplication
Specify the ports to be used by LDAP.
LocalLDAPPortToListenOn=50000
LocalSSLPortToListenOn=50001
Create a new application partition
NewApplicationPartitionToCreate="cn=IntranetApplication,dc=adatum,dc=com"
The following line specifies the directory to use for ADAM data files.
DataFilesPath=C:\Program Files\Microsoft ADAM\IntranetApplication\data
The following line specifies the directory to use for ADAM log files.
LogFilesPath=C:\ADAM Log Files\IntranetApplication\logs
The following line specifies the .ldf files to import into the ADAM schema.
ImportLDIFFiles="ms-inetorgperson.ldf" "ms-user.ldf"
Then enter the following command at the Run line or from the Windows command
prompt:
> adaminstall.exe /answer:<driveletter>:\<pathname>\<answerfile.txt>
628 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
654
|
The default location of adaminstall.exe is <driveletter>:\Windows
\ADAM. You must run this command from this location in the com‐
mand prompt.
Discussion
An AD LDS instance refers to a single installation of AD LDS on a particular server or
workstation. A single Windows computer can host multiple instances of AD LDS si‐
multaneously; they are all independently managed and use different LDAP and LDAPS
ports to communicate. Just as you can have multiple web servers operating on the same
computer, with one using TCP port 80 and one using TCP port 8081, you can also have
multiple AD LDS instances running simultaneously on different ports.
When you create an AD LDS instance, you also have the option to create an application
directory partition to associate with the instance. An AD LDS instance can have zero,
one, or multiple application partitions associated with it that will be used to store ap‐
plication data such as security principals as well as user and group information.
See Also
Recipe 18.7; MSDN: Binding to an Instance [ADAM]; “Create a New AD LDS In‐
stance”; Active Directory, Fifth Edition, by Brian Desmond et al. (O’Reilly)
18.3. Creating a New Replica of an AD LDS
Configuration Set
Problem
You want to create a new replica of an existing AD LDS configuration set.
Solution
Using a graphical user interface
1. From Administrative Tools, launch the Active Directory Lightweight Directory
Services Setup and then click Next.
2. Select the radio button next to “A replica of an existing instance” and click Next.
3. Enter the name of the instance that you want to create and click Next.
4. Enter the LDAP and SSL port numbers that will be used to access this instance;
these default to 50000 and 50001 on a domain controller or any computer that is
18.3. Creating a New Replica of an AD LDS Configuration Set | 629
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
655
|
already listening on the default LDAP port. Otherwise, the LDAP and SSL ports
that AD LDS chooses during the installation will be 389 and 636.
If you’ve already installed an ADAM instance on ports 50000 and
50001, the ADAM installer will choose the next two ports available;
the second ADAM instance would choose ports 50002 and 50003,
then 50004 and 50005, and so on.
5. On the Join a Configuration Set screen, enter the name of a server hosting an ex‐
isting replica of this instance, and the port number used to connect to it. Click Next
to continue.
6. On the Administrative Credentials for the Configuration Set screen, specify a user
or group account that has administrative rights to this AD LDS instance. This de‐
faults to the currently logged-on user, or you can click the radio button next to “This
account” and specify a different user or group. Click Next.
7. On the Copy Application Partitions screen, select the application directory parti‐
tions that you would like to replicate to the local server. Use the Add, Remove, Select
All, and Remove All buttons to select the appropriate partitions. Click Next to
continue.
8. Specify the directory that will house the instance data as well as its data recovery
files. These will both default to c:\Program Files\Microsoft ADAM\<instance name>
\data. Click Next.
9. On the Service Account Selection screen, configure the account under whose se‐
curity context this instance will run. By default, Network Service Account is se‐
lected, or you can click the radio button next to “This account” and specify a dif‐
ferent account.
10. On the AD LDS Administrators screen, specify the user or group account that will
have administrative rights to this instance. This defaults to the currently logged-on
user, or you can click the radio button next to “This account” and specify a different
user or group. Click Next.
11. Click Next and then Finish to create the new AD LDS replica.
Using a command-line interface on all versions
Create an answer file similar to the one listed here. Save it as new_replica_install.txt.
[ADAMInstall]
[ADAMInstall]
Install a replica of an existing AD LDS instance.
InstallType=Replica
630 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
656
|
Specify the name of the new replica.
InstanceName=IntranetApplication
Specify the ports used for LDAP and SSL.
LocalLDAPPortToListenOn=50000
LocalSSLPortToListenOn=50001
The following line specifies the directory to use for
ADAM data files.
DataFilesPath=C:\Program Files\Microsoft ADAM\IntranetApplication\data
The following line specifies the directory to use for ADAM log files.
LogFilesPath=C:\ADAM Log Files\IntranetApplication\logs
Specify the name of the a computer hosting an existing replica
SourceServer=servername
SourceLDAPPort=389
Then enter the following command at the Run line or from the Windows command
prompt:
> adaminstall.exe /answer:<driveletter>:\<pathname>\<answerfile.txt>
The default location of adaminstall.exe is <driveletter>:\Windows
\ADAM. You must run this command from this location in the com‐
mand prompt.
Discussion
Similar to Active Directory itself, AD LDS use multimaster replication that allows mul‐
tiple computers to host, read, and make updates to one or more configuration sets. An
AD LDS replica is a computer that is hosting one instance of a particular configuration
set. Unlike Active Directory, you can host replica instances on computers that run any
version of Windows since Windows XP (including client operating systems and server
operating systems). You are not restricted to replicating data to all of your AD LDS
servers unnecessarily; this can be quite useful in the case of data that is locally interesting
but that doesn’t need to be replicated throughout your entire environment.
See Also
Recipe 18.2 for creating a new AD LDS instance; “Create a Replica AD LDS Instance”
18.4. Stopping and Starting an AD LDS Instance
Problem
You want to start or stop an AD LDS instance.
18.4. Stopping and Starting an AD LDS Instance | 631
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
657
|
Solution
Using a graphical user interface
1. Open the Services MMC snap-in (services.msc).
2. Select the name of the AD LDS instance that you want to manage.
3. Right-click on the instance name and select Start, Stop, Pause, Resume, or Restart,
as needed.
Using a command-line interface
To stop an AD LDS instance, enter the following:
> net stop <instance_name>
To start an AD LDS instance, enter the following:
> net start <instance_name>
Using PowerShell
Start-Service "<AD LDS Instance Name>"
Stop-Service "<AD LDS Instance Name>"
Discussion
When you install an AD LDS instance on a computer (regardless of whether it is a new
or replica instance), the instance will advertise itself as a typical Windows service. The
service name naming convention is ADAM_<InstanceName>, where <InstanceName> is
the name you specified when you installed the instance. The display name of the service
will be just the <InstanceName>, where <InstanceName> is the name you specified when
you installed the instance. If you need to modify the display name of the service after
you’ve installed the AD LDS instance, you can use the built-in sc utility as follows:
> sc \\<servername> config <servicename> displayname = "<display name>"
See Also
Recipe 18.6 for listing the AD LDS instances installed on a computer; “Start, Stop, or
Restart an AD LDS Instance”
632 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
658
|
18.5. Changing the Ports Used by an AD LDS Instance
Problem
You want to change the LDAP or LDAP over SSL ports that are being used by a particular
AD LDS instance.
Solution
> dsdbutil
> activate instance <instancename>
> LDAP port <port>
> SSL port <port>
> quit
Discussion
If you need to change the LDAP and/or LDAP over SSL port that an instance is using
to communicate, you must first stop the instance using one of the methods specified in
Recipe 18.4. Once the instance has stopped, use dsdbutil as shown in this recipe’s
solution.
See Also
Recipe 18.4 for more on starting and stopping AD LDS instances; “Modify the Com‐
munication Ports Used by an AD LDS Instance”
18.6. Listing the AD LDS Instances Installed on a Computer
Problem
You want to list all of the AD LDS instances installed on a computer.
Solution
Using a command-line interface
To list all AD LDS instances installed on a computer, enter the following:
> dsdbutil
From the dsbutil: prompt, enter the following:
> list instances
18.5. Changing the Ports Used by an AD LDS Instance | 633
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
659
|
Using PowerShell
The following command will list all AD LDS instances whose name begins with "ADAM_"
on the local computer:
Get-Service -Include "ADAM_*"
Discussion
As we discussed in Recipe 18.4, a single computer can host multiple AD LDS instances
running on different ports, each of which will advertise itself as a typical Windows
service. These services will have a service name naming convention of ADAM_<Instan
ceName>, where <InstanceName> is the name that you specified when you installed the
instance. The name of the service will remain the same even if you change the display
name or description of the service at a later time, which can make the services.mscsnapin a less-than-desirable option for stopping and starting AD LDS instances if you make
a habit of renaming them. By querying for service names that include the string “ADAM”
using something like '%ADAM_%' in the WQL query, you can return the AD LDS in‐
stances that are installed on a local or remote computer. The method discussed in this
recipe will not help you, however, if someone has modified the Registry key containing
the name of the AD LDS instance. Locating AD LDS services can be a difficult task if
someone in your organization is trying to hide their AD LDS instance(s). One possible
solution, if you are having difficulty with this type of information gathering, would be
to perform a port scan on one or more target computers; once you’ve obtained a list of
listening ports, you can connect to each one in turn and look for an LDAP response.
In Windows Server 2008 and later, the "ADAM_" prefix was dropped from the service
display name, which makes the dsbutil option the most appropriate option for listing
AD LDS instances on a Windows Server 2008 instance.
See Also
Recipe 18.4; MSDN: Querying with WQL [WMI]; MSDN: WQL Operators [WMI];
“List the AD LDS Instances Installed on a Computer”
18.7. Extending the AD LDS Schema
Problem
You want to extend the AD LDS Schema with new classes or attributes.
634 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
660
|
Solution
Using a command-line interface
To extend the AD LDS Schema from the command line, you’ll need to create an LDIF
file containing the necessary schema extensions and then import it using the LDIFDE
command, or use a tool like AdMod to perform the changes. AD LDS comes with a
number of such LDIF files preinstalled that you can import during the AD LDS instal‐
lation process. If you did not import these files during installation, you can do so after
the fact using the following syntax:
> ldifde -i -f <driveletter>:\<pathname>\<Name of LDIF (.ldf) file>↵
-s <servername>:<portnumber> -k -j . -c "<Schema DN>" #schemaNamingContext
Discussion
The schema that you receive when you install AD LDS contains a subset of the classes
and attributes that exist in the Active Directory Schema. You have the same ability to
extend the schema in AD LDS as you do in AD, which means that you can expand and
modify the schema to be the same as the AD Schema, or to match any changes made
by your third-party or home-grown applications. Because of this, AD LDS is a great
place to test potential schema modifications that you want to make in Active Directory.
Because the schema extension process works the same in both AD and AD LDS, and
because you can easily install, uninstall, and reinstall AD LDS instances, you can use
AD LDS to quickly test new extensions, tweaking the definitions until you get exactly
what you want.
Every instance of AD LDS will have at least two partitions: the Configuration partition
and the Schema partition; you can create additional application partitions during or
after installation, as described in Active Directory, Fifth Edition, by Brian Desmond et
al. (O’Reilly). Similar to the Active Directory Schema NC, the AD LDS Schema partition
contains definitions of classes and attributes that can be used to create objects within a
particular AD LDS instance. An AD LDS Schema is unique to an individual AD LDS
instance or configuration set; changes to the schema in one instance or configuration
set will not affect the schema in other, separate instances or configuration sets. AD LDS
comes with a number of preconfigured LDIF files that you can import to create common
object types such as user, contact, and inetOrgPerson objects. You can import these
LDIF files during the initial creation of an AD LDS instance as well as after the instance
has been created.
Using a command-line interface
When updating the AD LDS Schema, be sure to use the version of ldifde that came with
AD LDS rather than any earlier versions of the utility.
18.7. Extending the AD LDS Schema | 635
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
661
|
See Also
Recipe 18.2; MSDN: Adding User Classes [ADAM]; MSDN: Adding Contact Classes
[ADAM]; MSDN: Extending the Active Directory Application Mode Schema [ADAM];
“Create an Application Directory Partition”; “Delete an Application Directory Parti‐
tion”; Active Directory, Fifth Edition, by Brian Desmond et al. (O’Reilly)
18.8. Managing AD LDS Application Partitions
Problem
You want to add or remove an application partition.
Solution
Using a graphical user interface
To add an application partition, do the following:
1. From the run prompt, open ldp.exe.
2. Click Connection→Connect to connect to the desired instance.
3. Click Connection→Bind to provide credentials to bind to the instance.
4. Click on Browse→Add child.
5. For DN, enter a distinguished name for the application partition.
6. Under “Edit entry”, enter ObjectClass in the Attribute box and container in the
Values box and then click Enter.
7. Under “Edit entry”, enter instanceType for the Attribute and 5 in the Values box,
and then click Enter.
8. Click Run.
To remove an application partition, do the following:
1. Open ADSI Edit. If necessary, create and bind to a connection of your AD LDS
instance.
2. Browse to the Partitions container (cn=Partitions). Right-click on the applica‐
tion directory partition that you want to delete and then click Delete.
3. Click Yes to confirm.
Using a command-line interface
Use the following sequence of commands to create an AD LDS application partition:
636 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
662
|
> dsmgmt
> Partition Management
> create nc <ApplicationPartitionDN> container <ComputerName>:<PortNumber>
> quit
> quit
Use the following command to delete an application partition:
> dsmgmt
> Partition Management
> delete nc <ApplicationPartitionDN>
> quit
> quit
Discussion
An AD LDS installation creates up to three partitions by default: Configuration, Schema,
and an application. The Configuration and Schema partitions get created automatically
during the creation of a new AD LDS instance; you can create application partitions
during the initial installation or after the instance has been created. If you’re installing
a replica of an existing configuration set, the existing Schema and Configuration par‐
titions are automatically replicated to the new instance. The Configuration partition
stores information about AD LDS replication and partitions, while the Schema partition
contains definitions for the types of objects that you can create within the instance. Note
that these partitions correspond quite closely to the Configuration and Schema naming
contexts within Active Directory.
When you create a new application directory partition, you need to specify a distin‐
guished name for the partition; this name needs to be unique within your environment.
See Also
MSDN: Using Application Directory Partitions [ADAM]; MSDN: Creating an Appli‐
cation Directory Partition [ADAM]; MSDN: Deleting an Application Directory Parti‐
tion [ADAM]; Chapter 20 of Active Directory, Fifth Edition, by Brian Desmond et al.
(O’Reilly)
18.9. Managing AD LDS Organizational Units
Problem
You want to create or delete OUs within an AD LDS instance.
18.9. Managing AD LDS Organizational Units | 637
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
663
|
Solution
Using a graphical user interface
1. Open ADSI Edit. If necessary, create and bind to a connection of your instance.
2. Right-click on the instance and select New→Object.
3. Under “Select a class”, click on organizationalUnit and click Next.
4. For the value of the ou attribute, type ADLDSUsers and click Next.
5. Click Finish.
6. To delete an OU, right-click on the object in question and select Delete.
Using a command-line interface
To create an ADAM OU from the command line, use the following syntax:
> admod -h <ComputerName>:<PortNumber> -b <OU DN>↵
objectClass::organizationalUnit -add
To delete an OU, replace the –add switch with –del in the previous statement.
A useful option in AdFind and AdMod for working with AD LDS is the
ability to create environment variables to specify long or often-used
switches. In this example, it would be quite useful to define an envi‐
ronment variable of adam-h that has a value of <ComputerName>:<Port
Number> and then that portion of the command can be shortened to -
e adam. See the AdFind usage screens for more information. If you work
with multiple instances, you can specify multiple environment vari‐
ables, such as adam1-h, adam2-h, and adam3-h, and then specify -e
adam1, -e adam2, or -e adam3 to access the different instances. You can
even specify adamx-u and adamx-up environment variables to specify
alternate credentials to connect to the various instances.
Using PowerShell
To create an organizational unit using Windows PowerShell, use the following syntax:
New-ADObject -Name "<OUName>" -Type OrganizationalUnit↵
-Server "<ComputerName>:<PortNumber>" -Path "<ParentContainerDN>"
To remove an organizational unit using Windows PowerShell, use the following syntax:
Remove-ADObject "<ObjectDN>" -Server "<ComputerName>:<PortNumber>"↵
-Confirm:$false
638 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
664
|
Discussion
Creating OUs in AD LDS is identical to creating them within Active Directory. Just like
in AD, AD LDS OUs are containers that can contain other objects such as users, groups,
contacts, or other OUs. You can also delegate permissions to an OU, allowing a user or
group to have rights to the OU itself and to objects within that OU.
Using a command-line interface
A useful feature of AdFind and AdMod is that, if you are working on ADAM or AD on
the local machine, you can use a period (.) for the hostname and it will expand that into
localhost for you.
See Also
Recipe 18.20 for more on managing AD LDS permissions; Chapter 5 for more on man‐
aging Active Directory OUs; “Add an Organizational Unit to the Directory”
18.10. Managing AD LDS Users
Problem
You want to create or delete user objects within an AD LDS instance.
Solution
Using a graphical user interface
1. Open ADSI Edit. If necessary, create a connection and bind to the necessary AD
LDS instance.
2. Right-click on the container that should house the user and select New→Object.
3. Under “Select a class”, click on “user” and click Next.
4. For the value of the cn attribute, type Joe Smith and click Next.
5. Click Finish.
Using a command-line interface
> admod -h <ComputerName>:<PortNumber> -b <User DN>objectClass::user -add
18.10. Managing AD LDS Users | 639
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
665
|
Using PowerShell
To create an AD LDS user with PowerShell, use the following syntax:
New-ADUser -Name "John Doe" -Server "<ComputerName>:<Port Number>"↵
-Path "<Application/Parent DN>" -AccountPassword (ConvertTo-SecureString↵
-AsPlainText "<PlainTextPassword>" -Force)
To remove an AD LDS user with PowerShell, use the following syntax:
Remove-ADUser "<User DN>" -Server "<ComputerName>:<Port Number>" -Confirm:$false
Discussion
Creating users in AD LDS is quite similar to creating users in Active Directory. The
most significant difference is that AD LDS users do not have the sAMAccountName
attribute. You could conceivably define such an attribute within AD LDS and associate
it with the user class, but it will not have the same properties that it does in Active
Directory, particularly the AD constraint in which sAMAccountName uniqueness is en‐
forced across a domain. AD LDS also would not be able to use a manually created
attribute like that for user logons the way that sAMAccountName is used in AD.
If you create an AD LDS user without creating a password for it, the
object will be disabled until you enable it.
See Also
Recipe 18.11 to configure the password for an AD LDS user; MSDN: Managing Users
[ADAM]; MSDN: Set or Modify the Password of an ADAM User [ADAM]; “Add an
AD LDS User to the Directory”
18.11. Changing the Password for an AD LDS User
Problem
You want to change the password for an AD LDS user.
Solution
Using a graphical user interface
1. Open ADSI Edit. If necessary, create a connection and bind to the necessary AD
LDS instance.
640 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
666
|
2. Navigate to the container that houses the user.
3. Right-click the user and click Reset Password.
4. Enter the new password twice and click OK.
Using PowerShell
Set-ADAccountPassword "<User DN>" -Server "<ComputerName>:<PortNumber>"↵
-NewPassword (ConvertTo-SecureString -AsPlainText "<PlainTextPassword>" -Force)
Discussion
To create user objects within an AD LDS instance, you first need to import the optional
LDIF files that are provided with the AD LDS installer into the AD LDS schema, in‐
cluding ms-User.ldf, ms-InetOrgPerson.ldf, and ms-UserProxy.ldf. The ms-user.ldf file
allows you to create Person, organizational-Person, and User objects. Any AD LDS
user objects that you create will adhere to whatever local or domain password and
account lockout policies are in place on the server that’s hosting the instance. You can
use the procedures listed here to change the password for an AD LDS user, or to set a
password for an AD LDS user that was created without specifying an initial password.
Using a command-line interface
You can also use ldifde to set or change an ADAM or AD LDS user’s password, but it
requires a 128-bit SSL connection with a certificate installed on the computer that’s
running the instance.
You can also perform this using the -kerbenc switch in admod, as follows:
> admod -h . -b cn=jsmith,o=test userpassword::mypasswordQ1 -kerbenc
See Also
MSDN: Setting User Passwords [ADAM]; “Modify the Password of an AD LDS User”
18.12. Enabling and Disabling an AD LDS User
Problem
You want to enable or disable an AD LDS user object.
18.12. Enabling and Disabling an AD LDS User | 641
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
667
|
Solution
Using a graphical user interface
1. Open ADSI Edit. If necessary, create and bind to a connection of your AD LDS
instance.
2. Navigate to the user in question, right-click, and select Properties.
3. Scroll to the msDS-UserAccountDisabled attribute and click Edit.
4. Click True and then click OK.
5. To reenable the AD LDS user account, modify the msDS-UserAccountDisabled
attribute to have a value of False.
Using a command-line interface
To disable an AD LDS user from the command line, enter the following syntax:
> admod -h <ComputerName>:<PortNumber> -b <User DN>↵
msDS-UserAccountDisabled::TRUE
To enable or reenable a user account, change TRUE to FALSE in the previous command.
When configuring this attribute, TRUE and FALSE are case-sensitive and
must be specified using all uppercase letters.
Using PowerShell
To enable an AD LDS user account, use the following syntax:
Set-ADUser <User DN> -Replace @{"msDS-UserAccountDisabled"=$false}↵
-Server "<ComputerName>:<Port Number>"
To disable an AD LDS user account, use the following syntax:
Set-ADUser <User DN> -Replace @{"msDS-UserAccountDisabled"=$true}↵
-Server "<ComputerName>:<Port Number>"
Discussion
AD LDS users can be enabled or disabled by modifying the msDSUserAccountDisabled property. A new user will be enabled by default when you first
create it, unless the password you’ve assigned for it doesn’t meet the requirements of
the password policy, which is in effect on the machine.
642 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
668
|
See Also
Recipe 18.11 for more on setting the password of an AD LDS user; MSDN: ms-DSUser-Account-Disabled Attribute [AD Schema]; “Disable or Enable an AD LDS User”
18.13. Creating AD LDS Groups
Problem
You want to create or delete a group object within AD LDS.
Solution
Using a graphical user interface
1. Open ADSI Edit. If necessary, create and bind to a connection of your AD LDS
instance.
2. Right-click on the instance and select New→Object.
3. Under “Select a class,” click on group and click Next.
4. For the value of the cn attribute, type ADLDSGroup and click Next.
5. For the sAMAccountName attribute, enter ADLDSGroup and then click Next.
6. Click Finish.
7. To delete a group object, right-click on the object in question and select Delete.
Using PowerShell
To create a group object using Windows PowerShell, use the following syntax:
New-ADGroup -Name "<Name>" -GroupScope "<Scope>" -Path "<Parent DN>"↵
-Server "<ComputerName>:<PortNumber>"
To remove a group object using Windows PowerShell, use the following syntax:
Remove-ADGroup -Identity "<Object DN>" -Server "<ComputerName>:<PortNumber>"↵
-Confirm:$false
Discussion
Group objects in AD LDS are greatly simplified compared to their Active Directory
counterparts, since the notion of security and distribution groups as two separate en‐
tities does not exist. In addition, all AD LDS groups have the same scope: a group that
has been created within an application partition can only be used within that partition,
whereas a security principal that’s been created in the Configuration NC can be used in
18.13. Creating AD LDS Groups | 643
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
669
|
all naming contexts in that instance. This means that a group or user that was created
in Instance1 cannot be used to assign permissions on objects in Instance2 or be added
to a group in Instance2 (unless Instance1 and Instance2 are members of the same
configuration set). Windows security principals can be assigned permissions in any
application partition. And just like AD LDS user objects, AD LDS group objects do not
contain the sAMAccountName attribute.
When you first install an AD LDS instance, you have three default
groups that are installed in the cn=Roles container: Administrators,
Readers, and Users.
See Also
MSDN: Enumerating Users and Groups [ADAM]; MSDN: Creating Groups [ADAM];
“Add an AD LDS Group to the Directory”; MSDN: Deleting Groups [MSDN]; Active
Directory, Fifth Edition, by Brian Desmond et al. (O’Reilly)
18.14. Managing AD LDS Group Memberships
Problem
You want to manage the groups that an AD or AD LDS user is a member of.
Solution
Using a graphical user interface
1. Open ADSI Edit. Connect and bind to the instance you want to manage.
2. Navigate to the group in question, right-click, and select Properties.
3. Scroll to the member attribute and click Edit.
4. To add a Windows user to the group, click Add Windows Account and enter the
name of the Windows account. To add an AD LDS user, click Add DN and then
enter the DN of the user that you want to add. Repeat this to add additional users.
5. To remove members, click on the CN of the object you wish to remove and then
click Remove. Repeat this to remove additional users from the group.
Using a command-line interface
To add a Windows user to a group from the command line, enter the following syntax:
> admod -h <ComputerName>:<PortNumber> -b <GroupDN> member:+:<UserDN>
644 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
670
|
To add multiple users at one time, change + to ++ in the previous command and separate
the User DNs with a semicolon.
To remove a single user, change + to – in the previous command.
To remove multiple users, change + to –– in the previous command and separate the
User DNs with a semicolon.
Using PowerShell
To add users to AD LDS groups using PowerShell, use the following syntax:
Add-ADGroupMember -Identity "<GroupDN>" -Members "<UserDN>"↵
-Server "<ComputerName>:<PortNumber>" -Partition "<PartitionDN>"
To remove users from AD LDS groups using PowerShell, use the following syntax:
Remove-ADGroupMember -Identity "<GroupDN>" -Members "<UserDN>"↵
-Server "<ComputerName>:<PortNumber>" -Partition "<PartitionDN>"↵
-Confirm:$false
Discussion
AD LDS group objects can contain both AD LDS users and Windows security principals,
which allows you to assign permissions to data stored in AD LDS instances using a
consistent method. In the case of groups that were created within a specific application
partition, they can only be assigned permissions within that partition; groups that were
created within the Configuration partition can be assigned permissions to objects in
any partition within the instance.
Using a command-line interface
To insert a Windows principal into an ADAM/AD LDS group, you need to know either
the ForeignSecurityPrincipal or the userProxy object that the Windows user is tied
to within the instance; otherwise, you need to add the user by its DN as done here.
See Also
MSDN: Adding a User to a Group [ADAM]; MSDN: Removing Members from Groups
[ADAM]; “Add or Remove Members to or from an AD LDS Group”
18.15. Viewing and Modifying AD LDS Object Attributes
Problem
You want to view the attributes of an object within an AD LDS instance.
18.15. Viewing and Modifying AD LDS Object Attributes | 645
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
671
|
Solution
Using a graphical user interface
1. Open ADSI Edit. If necessary, connect and bind to a connection of your AD LDS
instance.
2. Navigate to the object in question, right-click, and select Properties. To view only
the mandatory attributes for an object, click Filter and then remove the checkmark
next to Optional. To view only the optional attributes for an object, place a check‐
mark next to Optional and remove the checkmark next to Mandatory.
3. Scroll through the object’s properties. To modify a particular property, select the
property and select Edit.
4. To insert a value into a single-valued attribute, enter the value and click OK. To
remove a value from a single-valued attribute, click Clear.
5. To insert one or more values into a multivalued attribute, enter each value and click
Add. To remove one or more values from a multivalued attribute, select the value
and click Remove.
Using a command-line interface
To view the attributes of an object, enter the following:
> adfind -h <ComputerName>:<PortNumber> -b <ObjectDN> -s base
To restrict the AdFind output to only a few attributes, specify the name
of each attribute you want to view after the ObjectDN; to view multiple
attributes, separate each one with spaces in between. You can also use
the -excl switch to display all but one or two attributes.
To insert a value into a single-valued attribute, enter the following syntax:
> admod -h <ComputerName>:<PortNumber> -b <ObjectDN> <AttributeName>::<Value>
To insert multiple values into a multivalued attribute, change <AttributeName>:: to
"<AttributeName>:++:<Value>;<Value>" in the previous command.
To clear an attribute’s value (whether a single- or a multivalued attribute), enter the
following:
> admod -h <ComputerName>:<PortNumber> -b <ObjectDN> <AttributeName>:-
To remove a single value from a multivalued attribute, change - to -- in the previous
command and then add the value that you want to remove.
646 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
672
|
Using PowerShell
To view an AD LDS object’s properties using Windows PowerShell, use the following
syntax:
Get-ADObject -Identity "<Object DN>" -Server "<ComputerName>:<Port Number>"↵
-Properties *
To modify an AD LDS object’s properties using Windows PowerShell, use the following
syntax:
Set-ADObject -Identity "<Object DN>" -Server "<ComputerName>:<Port Number>"↵
-Add @{"<Attribute"="<Value>"}
Discussion
Just like in Active Directory, each AD LDS instance possesses a schema that defines
what types of objects you can create and what sorts of attributes those objects possess.
One of the major advantages of working with AD LDS is that you can make changes to
the schema of an AD LDS instance without affecting the AD schema, thus allowing for
more flexible application development that doesn’t run the risk of making permanent
or far-reaching changes to an entire Active Directory forest. Similar to AD, object classes
can have both mandatory and optional attributes that you can view.
See Also
MSDN: Active Directory Application Mode Schema [ADAM]; MSDN: Extending the
Active Directory Application Mode Schema [ADAM]
18.16. Importing Data into an AD LDS Instance
Problem
You want to perform a bulk import of object data into an AD LDS instance.
Solution
Using a command-line interface
To import objects using the ldifde utility, you must first create an LDIF file with the
objects to add, modify, or delete. Here is an example LDIF file that adds three users to
an AD LDS application partition:
dn: cn=Joe Smith,cn=users,ou=AdamUsers,o=adatum,c=us
changetype: add
objectClass: user
cn: Joe Smith
name: Joe Smith
18.16. Importing Data into an AD LDS Instance | 647
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
673
|
dn: cn=Richard Mahler,cn=users,ou=AdamUsers,o=adatum,c=us
changetype: add
objectClass: user
cn: Richard Mahler
name: Richard Mahler
dn: cn=Doug Martin,cn=users,ou= AdamUsers,o=adatum,c=us
changetype: add
objectClass: user
cn: Doug Martin
name: Doug Martin
Once you’ve created the LDIF file, you just need to run ldifde to import the new objects:
> ldifde -i -f c:\import.ldf -s <servername>:<portnumber> -k
Be sure to use the most current version of ldifde available.
Discussion
For more information on the LDIF format, check RFC 2849.
Using a command-line interface
To import with ldifde, simply specify the -i switch to turn on import mode and -f
<filename> for the file. It can also be beneficial to use the -v switch to turn on verbose
mode to get more information in case of errors. The –j switch can be used to specify
the path of the logfile location.
See Also
Recipe 4.29 for information on importing data using LDIF files; RFC 2849 (The LDAP
Data Interchange Format [LDIF]—Technical Specification); “Import or Export Direc‐
tory Objects Using Ldifde”
18.17. Configuring Intra-Site Replication
Problem
You want to create a replication schedule for an AD LDS application partition that is
hosted on multiple computers within a single site.
648 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
674
|
Solution
Using a graphical user interface
1. Open Active Directory Sites and Services (dssite.msc). If necessary, connect and
bind to a connection of your AD LDS instance.
In order to use the AD Sites and Services MMC snap-in to manage
AD LDS replication, you must use the MS-ADLDSDisplaySpecifiers.LDF file to extend the schema of the configuration
set that you are managing.
2. Navigate to the Sites container and click the name of the site you need to modify.
3. Right-click cn=NTDS Site Settings and then click Properties.
4. Click Change Schedule. Select the block of time that should be available for repli‐
cation. For every available block of time, you can configure the replication fre‐
quency to None, Once per Hour, Twice per Hour, or Four Times per Hour. Click
OK when you’re finished.
Discussion
Like Active Directory, AD LDS uses multimaster replication to copy information be‐
tween replicas of each member of a configuration set. By default, all AD LDS instances
that you create will be placed within a single site, Default-First-Site-Name. Similar
to AD, AD LDS’s intra-site replication takes place through update notifications, where
replication partners are notified as changes occur.
See Also
MSDN: Active Directory Application Mode Schema [ADAM]; MSDN: Using Applica‐
tion Directory Partitions [ADAM]; “Configure Replication Frequency Within a Site”
18.18. Forcing AD LDS Replication
Problem
You want to force immediate replication of an AD LDS application partition.
18.18. Forcing AD LDS Replication | 649
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
675
|
Solution
Using a graphical user interface
1. Open Active Directory Sites and Services (dssite.msc). If necessary, connect and
bind to a connection of your AD LDS instance.
2. Navigate to the Site container and then expand the Servers container. Expand the
server name and click NTDS Settings.
3. Right-click the connection and click Replicate Now. Click OK.
Using a command-line interface
> repadmin /syncall <servername>:<port> <AppPartitionDN>
Discussion
The repadmin command-line tool that comes with both AD and AD LDS is primarily
used to display and manage the replication topology of multiple directory servers. But
repadmin can do much more, such as allowing you to view object metadata, update
Service Principal Names (SPNs), and display information on trust relationships. You
can see all of the basic options that are available by typing repadmin /? at a command
prompt. Once you’ve familiarized yourself with these switches, you can then start learn‐
ing about the more advanced features available by typing repadmin /experthelp.
repadmin is one of those indispensable tools for an AD or AD LDS administrator; it’s
well worth the time to learn its ins and outs to help you monitor and troubleshoot your
network.
See Also
MS KB 229896 (Using Repadmin.exe to Troubleshoot Active Directory Replication);
MS KB 905739 (TechNet Support WebCast: Troubleshooting Active Directory replica‐
tion using the Repadmin tool)
18.19. Managing AD LDS Replication Authentication
Problem
You want to manage the security of AD LDS replication.
650 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
676
|
Solution
Using a graphical user interface
1. Open ADSI Edit. Connect and bind to the Configuration container of the AD LDS
instance that you wish to manage.
2. Double-click on Configuration [<ComputerName>:<PortNumber>].
3. Right-click on cn=Configuration,cn=<GUID> and click Properties.
4. Scroll to msDS-ReplAuthenticationMode. Double-click on the attribute and enter
one of the following values:
2
Mutual authentication with Kerberos
1
Negotiated authentication
0
Negotiated pass-through authentication
Using a command-line interface
> admod -h <ComputerName>:<PortNumber> -b <ConfigDN>↵
msDS-ReplAuthenticationMode::<AuthenticationMode>
Using PowerShell
Set-ADObject -Identity "<ConfiguratoinDN>" -Partition "<PartitionDN>"↵
-Replace @{"msDS-ReplAuthenticationMode"="<AuthenticationMode>"}↵
-Server "<ComputerName>:<Port Number>"
Discussion
To ensure replication security, AD LDS will authenticate replication partners within a
configuration set before replication begins. The method used for replication authenti‐
cation will depend on the value of the msDS-ReplAuthenticationMode attribute on the
configuration directory partition. After replication partners have successfully authen‐
ticated, all replication traffic between the two partners is encrypted. AD LDS uses Se‐
curity Support Provider Interface (SSPI) to establish the appropriate authentication
security level between replication partners, and replication authentication always occurs
over a secure channel.
Table 18-1 lists the security levels for replication authentication in Windows Server 2008,
Windows Server 2008 R2, and Windows Server 2012. The default replication security
level for a new, unique AD LDS instance is 1, unless a local workstation user account is
18.19. Managing AD LDS Replication Authentication | 651
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
677
|
specified as the AD LDS service account, in which case the replication security level is
set to 0.
Table 18-1. Description of the msDS-ReplAuthenticationMode values
Value Description
0—
Negotiated
pass-through
All AD LDS instances in the configuration set use an identical account name and password as the AD LDS service
account. Using this replication authentication value, a configuration set can include computers that are joined
to one or more workgroups and/or computers that are joined to one or more untrusted domains or forests. This
is the default value if a local user account is specified as the AD LDS service account for the configuration set.
1—
Negotiated
Kerberos authentication (using SPNs) is attempted first. If Kerberos fails, NTLM authentication is
attempted. If NTLM fails, the AD LDS instances will not replicate. This is the default value for a configuration set,
unless it is configured with a local account as the AD LDS service account.
2—Mutual
authentication
with Kerberos
Kerberos authentication, using service principal names (SPNs), is required. If Kerberos authentication
fails, the AD LDS instances will not replicate. If this value is selected, the configuration set must be fully contained
within an AD DS domain or within computers belonging to trusted domains or forests.
See Also
MSDN: Active Directory Application Mode Schema [ADAM]; MSDN: Using Applica‐
tion Directory Partitions [ADAM]; “Modify the Replication Security Level of a Con‐
figuration Set”
18.20. Managing AD LDS Permissions
Problem
You want to manage permissions within an AD LDS instance.
Solution
Using a graphical user interface
1. Launch LDP.exe. Connect and bind to the object or container that you wish to
modify.
2. Right-click on the object or container and select Advanced→Security Descriptor.
3. To display and edit auditing information in addition to the Discretionary Access
Lists (DACLs) associated with the object, place a checkmark next to SACL. Click
OK.
4. To delete an Access Control Entry (ACE), highlight the entry and click Delete.
5. To add an entry, click Add.
652 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
678
|
6. In the Trustee text box, enter the name of the user or group object that you wish
to apply permissions to. In the ACE mask section, select whether you are creating
Allow ACE or Deny ACE.
7. In the Access mask section, place checkmarks next to the permissions that you are
allowing or denying.
8. Click OK when you are finished.
Using a command-line interface
To view the effective permissions on an AD LDS object, use the following syntax:
> dsacls \\<servername>:<port>\<ObjectDN>
To grant permissions on an AD LDS object, use the following:
> dsacls "\\<servername>:<port>\<ObjectDN>"↵
/G <User or Group ReceivingPermissions>:<Permission Statement>
To deny permissions on an AD LDS object, use the following:
> dsacls "\\<servername>:<port>\<ObjectDN>"↵
/D <User or Group ReceivingPermissions>:<Permission Statement>
Discussion
The LDP utility provides you the ability to modify both DACL and SACL entries at an
extremely granular level. You also have the familiar dsacls utility that will allow you to
delegate permissions from the command line. When delegating permissions, you must
first determine whether you are delegating permission over an entire container and all
objects contained therein, or whether you are only going to delegate control over specific
child objects. (For example, you can delegate control over all AD LDS user objects within
an OU.) Once you’ve made this determination, you’ll then designate the specific per‐
missions that you’re delegating; you can delegate anything from full control of the entire
object down to granting read permissions on a single attribute.
Using a command-line interface
dsacls requires a specific syntax for the permission statement used to grant or deny
permissions, formatted in this manner:
[PermissionBits];[{Object|Property}];[InheritedObjectType]
[PermissionBits] here refers to any of the values listed in Table 18-2; you can specify
one or more together with no spaces between them.
18.20. Managing AD LDS Permissions | 653
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
679
|
Table 18-2. Description of the PermissionBits values
Value Description
GR Generic read
GE Generic execute
GW Generic write
GA Generic all (FULL CONTROL)
SD Delete
DT Delete an object and all its child objects (DELETE TREE)
RC Read security information
WD Change security information
WO Change owner information
LC List child objects
CC Create child objects
DC Delete child objects
WS Write to self
RP Read property
WP Write property
CA Control access
LO List object access
The [Object | Property] option allows you to delegate permissions for an entire
object, or for only specific properties of that object. For example, you can delegate the
Write Property permission for all properties of an object, or only one or two specific
properties.
See Also
“View or Set Permissions on a Directory Object”
18.21. Enabling Auditing of AD LDS Access
Problem
You want to enable auditing of directory access and modifications. Audit events are
logged to the Security event log.
654 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
680
|
Solution
Using a graphical user interface
1. Open the Group Policy Object (GPO) that is linked to the computer(s) hosting the
AD LDS instance that you wish to audit.
2. In the left pane, expand Windows Settings→Security Settings→Local Policies and
click on Audit Policy.
3. In the right pane, double-click “Audit directory service access”.
4. Check the box beside Success and/or Failure.
5. Click OK.
Using a command-line interface
To modify the audit policy, use the following syntax:
auditpol /set /category:"<category>" /success:enable /failure:enable
To view the list of categories, use the following syntax:
auditpol /list /category
Discussion
Since Windows Server 2008, additional auditing functionality is enabled, which allows
auditing of Directory Services events, including capturing "before" and "after" values
on changes and deletions to Active Directory objects. You can enable this functionality
using the auditpol.exe tool discussed earlier, using syntax similar to the following:
auditpol /set /subcategory:"directory service changes"
Here is a sample event that was logged after the Administrator account created a user
object called JSmith in the Sales OU:
Log Name: Security
Source: Microsoft Windows security auditing
Date: 11/13/2012 3:50:58 AM
Event ID: 5137
Task Category: Directory Service Changes
Level: Information
Keywords: Audit Success
User: N/A
Computer: dc01.adatum.us
Description:
A user account was created.
Subject:
Security ID: ADATUM\Administrator
18.21. Enabling Auditing of AD LDS Access | 655
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
681
|
Account Name: Administrator
Account Domain: ADATUM
Logon ID: 0xb3405
Directory Service:
Name: ADAM_Partition1
Type: Active Directory Lightweight Directory Services
Object:
DN: cn=JSmith,cn=Container1,cn={61E04C68-5582-494D-9F0A-1E0B970Db2D3}
GUID: {7c427193-64f6-476f-9cf4-748d850f02f8}
Class: User
Operation:
Correlation ID: {dbae9153-eae6-49cd-b641-fbef24d19cee}
Application Correlation ID: -
In an Active Directory environment it can also be useful to enable Audit
Account Management in the GPO that’s linked to the Domain
Controllers OU. This provides additional information about account
management operations—for example, finding what account deleted a
certain object.
656 | Chapter 18: Active Directory Lightweight Directory Service
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
682
|
CHAPTER 19
Active Directory Federation Services
19.0. Introduction
Active Directory Federation Services (AD FS) was introduced in Windows Server 2003
R2 as version 1.0, updated for Windows Server 2008 (version 1.1), released as a stand‐
alone product in version 2.0, and then updated for Windows Server 2012 (2.1). It is used
to allow single sign-on (SSO) capabilities to web applications hosted by multiple or‐
ganizations without the need to configure an Active Directory trust relationship be‐
tween them. This task is performed by using AD FS servers to separate the process of
authentication (proving who a user is) from that of authorization (specifying what a
user can do). AD FS allows this separation by configuring account partners to authen‐
ticate users and groups, and then providing claims to resource partners that control the
actual access to resources.
This relationship between account partners and resource partners is called a federated
trust. This verbiage can sometimes lead to confusion, since it seems to imply that AD
FS requires an Active Directory trust relationship to exist between account and resource
partners. In this case, the word trust merely refers to a business agreement between two
organizations that have agreed to this type of distributed authentication and authori‐
zation arrangement. A federated trust refers to a scenario in which the AD FS Federation
Service has been properly configured by both the organization that performs user au‐
thentication and the organization that controls access to web resources.
There are two AD FS 2.0 designs. One design, the Web SSO design, is used for authen‐
ticating access to web applications in a perimeter network environment. This design is
typically used when there isn’t a partner organization and all users are external. The
other common AD FS design, Federated Web SSO, is commonly used by two separate
organizations (most notably in a B2B relationship) for whom an Active Directory forest
trust would create too much access for users on both sides of the equation or where
Selective Authentication would require too much ongoing maintenance.
657
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
683
|
19.1. Installing AD FS Prerequisites
Problem
You want to preinstall the necessary prerequisites before installing AD FS. The GUI
steps are specific to Windows Server 2012 but also very close to what is found in Win‐
dows Server 2008 and Windows Server 2008 R2.
Solution
Using a graphical user interface
To install IIS on a server, follow these steps:
1. Launch Server Manager.
2. Click Manage and then click Add Roles and Features.
3. Click Next twice.
4. Place a checkmark next to Web Server (IIS). If prompted, click Add Required Fea‐
tures. Click Next twice.
5. Place a checkmark next to ASP.NET and Windows Authentication. If prompted,
click Add Required Role Services.
6. Click Next and then click Install.
7. When the installation completes, click Close.
To enable SSL for the Default Web Site, do the following:
1. Open the Internet Information Service (IIS) Manager snap-in (iis.msc).
2. Drill down to <server name>. In the right-hand pane, double-click on Server
Certificates.
3. Click on Create Certificate Request. Enter the identifying information for the cer‐
tificate request. Click Next.
4. Select the desired Cryptographic Service Provider and Bit length, and then click
Next.
5. Specify a name for the Certificate request and then click Next.
658 | Chapter 19: Active Directory Federation Services
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
684
|
Once you have submitted the certificate request to a Certification Authority and have
received a .cer file in return, use these steps to install the certificate:
1. Navigate to <server name> if you have not done so already. Click “Complete cer‐
tificate request.”
2. Browse to the appropriate CER file, and enter the FQDN of the server in the Friendly
name field. Click OK.
3. Browse to Sites→Default Web Site. Right-click on Default Web Site and click Edit
Bindings.
4. Click Add. In the Type: drop-down box, select https. In the IP Address: drop-down
box, select the IP address of the server. Confirm that the Port text box reads 443.
In the “SSL certificate:” drop-down box, select the SSL certificate that you installed
in steps 1 and 2.
5. Click OK and then click Close.
6. In the middle pane, double-click on SSL Settings. On the SSL Settings page, place
a checkmark next to Require SSL. In the “client certificates:” radio buttons, select
Accept. Click Apply.
Using a command-line interface
To generate a certificate request via the command line, you must first create a re
quest.inf file similar to the following:
;----------------- request.inf -----------------
[Version]
Signature="$Windows NT$
[NewRequest]
Subject = "cn=<DC FQDN>" ; replace with the FQDN of the DC
KeySpec = 1
KeyLength = 2048
; Can be 1024, 2048, 4096, 8192, or 16384.
; Larger key sizes are more secure, but have
; a greater impact on performance.
Exportable = TRUE
MachineKeySet = TRUE
SMIME = False
PrivateKeyArchive = FALSE
UserProtected = FALSE
UseExistingKeySet = FALSE
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
RequestType = PKCS10
19.1. Installing AD FS Prerequisites | 659
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
685
|
KeyUsage = 0xa0
[EnhancedKeyUsageExtension]
OID=1.3.6.1.5.5.7.3.1 ; this is for Server Authentication
;-----------------------------------------------
Once you have created the appropriate request.inf file, issue the following certreq.exe
command:
> certreq -new request.inf request.req
Once you have submitted the certificate request to a Certification Authority and have
received a .cer file in return, use the following command to install the certificate:
> certreq -accept newcert.cer
Discussion
You need to install an SSL certificate on the IIS server before configuring AD FS. You
can configure a certificate from a commercial CA or one internal to your environment,
or else you can install a self-signed certificate if you are operating in a test environment.
Self-signed certificates should not be used in a production or public-facing server
environment.
Note that the installation of the AD FS Federation Service will automatically install
prerequisites. For many administrators, this makes it more efficient. However, some
organizations prefer to split up the different phases of the installation due to change
control requirements or segmented administration teams controlling different parts of
the environment.
See Also
“How to enable LDAP over SSL with a third-party certification authority”
19.2. Installing the AD FS Federation Service
Problem
You want to install the AD FS Federation Service on a server.
Installing the Federation Service presumes that the server in question
is joined to an Active Directory domain.
660 | Chapter 19: Active Directory Federation Services
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
686
|
Solution
Using a graphical user interface
1. Launch Server Manager.
2. Click Manage and then click Add Roles and Features.
3. Click Next. Select the server to install the role on and then click Next.
4. Place a checkmark next to Active Directory Federation Services. If prompted, click
Add Features. Click Next three times.
5. Ensure that a checkmark is next to Federation Service.
6. Click Next three times and then click Install.
7. When the installation completes, click Close.
Using PowerShell
Install-WindowsFeature ADFS-Federation -IncludeAllSubFeature↵
-IncludeManagementTools
Discussion
The functionality of the AD FS Federation Service in Windows Server 2012 is funda‐
mentally identical to AD FS 2.0 running on a 2008 R2 server. However, note that Win‐
dows Server 2008 R2 comes with AD FS version 1.1 built in. Version 2.0 has to be
downloaded and installed. Since AD FS 2.1 comes as a role in Windows Server 2012,
you get an enhanced installation experience (validation checks during installation and
dependency checks during installation).
See Also
Recipe 19.1; “Best Practices for Secure Planning and Deployment of AD FS 2.0”
19.3. Configuring an LDAP Attribute Store
Problem
You want to configure AD FS to use an instance of LDAP for attributes.
19.3. Configuring an LDAP Attribute Store | 661
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
687
|
Solution
Using a graphical user interface
1. Open the AD FS MMC snap-in (adfs.msc).
2. From the Actions menu, select Add Attribute Store.
3. Enter a name in the Display name field.
4. Select LDAP as the Attribute store type.
5. In “Connection string”, enter the string to be used for the connection for the at‐
tribute store; for example, dc=adatum,dc=com.
6. Click OK to add the LDAP attribute store.
Using Windows PowerShell
Add-ADFSAttributeStore -Name "<Name>" -StoreType LDAP↵
-Configuration @{"Name"="<Description>"; "Connection"="<AD LDS DN>"}
Discussion
LDAP attribute stores are configured quite similarly to Active Directory stores; you can
configure multiple LDAP attribute stores on a given federation server. You can also
modify the default timeout period for searches; the default is five seconds. In addition,
you can enable SSL/TLS to encrypt the connection between the federation server and
the web server hosting the application.
See Also
Chapter 18 for more on configuring LDAP instances and application partitions
19.4. Configuring a Microsoft SQL Server Attribute Store
Problem
You want to configure AD FS to use a Microsoft SQL Server attribute store for attributes.
Solution
Using a graphical user interface
1. Open the AD FS MMC snap-in (adfs.msc).
2. From the Actions menu, select Add Attribute Store.
662 | Chapter 19: Active Directory Federation Services
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
688
|
3. Enter a name in the Display name field.
4. Select SQL as the Attribute store type.
5. In “Connection string”, enter the string to be used for the connection to the attribute
store; for example, Server=adatum-sql;Database=userDatabase;Integrated Se
curity=True
6. Click OK to add the SQL attribute store.
Using Windows PowerShell
Add-ADFSAttributeStore -Name "<Name>" -StoreType SQL↵
-Configuration @{"Name"="<Description>"; "Connection"=↵
"<SQL Connection String>"}
Discussion
SQL attribute stores allow you to use a SQL database to store attributes.
19.5. Creating Claim Descriptions
Problem
You want to add a new type of claim that can be used by claims-aware applications.
Solution
Using a graphical user interface
1. Open the AD FS MMC snap-in (adfs.msc). Navigate to AD FS→Service→Claim
Descriptions.
2. From the Actions menu, click Add Claim Description.
3. Enter a name for the claim description and then enter a claim identifier.
4. Add a description and then select the publishing options.
5. Click OK to create the claim description.
Using Windows PowerShell
Add-ADFSClaimDescription -Name "<Name>" -ClaimType "<ClaimURI>" -IsAccepted↵
$True -IsOffered $True
19.5. Creating Claim Descriptions | 663
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
689
|
Discussion
AD FS claims are the foundation of authentication and authorization in federated ap‐
plications. Administrators in account partners will configure organizational claims that
will be presented by users when accessing applications that are hosted by resource
partners.
See Also
Recipe 19.6 for more on configuring an account partner; Recipe 19.7 for more on con‐
figuring a claims provider trust
19.6. Creating a Relying Party Trust
Problem
You want to configure a relying party trust to allow your organization’s users to access
applications that are managed by an AD FS resource partner.
Solution
Using a graphical user interface
1. Open the AD FS MMC snap-in (adfs.msc).
2. From the Actions menu, click Add Relying Party Trust.
3. Click Start to begin the Add Relying Party Trust Wizard.
4. To create a relying party manually, click “Enter data about the relying party man‐
ually” and then click Next.
5. On the Specify Display Name screen, enter the display name and notes of the relying
party, and then click Next.
6. On the Choose Profile screen, select the appropriate AD FS profile and then click
Next.
7. On the Configure Certificate screen, specify a token encryption certificate that will
be used to encrypt outgoing requests and then click Next.
8. On the Configure URL screen, select the appropriate protocols and enter the re‐
spective URLs, if necessary.
9. On the Configure Identifiers screen, enter the relying party’s trust identifier and
then click Add. Click Next to continue.
10. On the Choose Issuance Authorization Rules screen, select the authorization rule
for the relying party trust.
664 | Chapter 19: Active Directory Federation Services
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
690
|
11. Click Next and then Close to complete the wizard.
Using Windows PowerShell
Add-ADFSRelyingPartyTrust -Name "<Name>" -Identifier "<URI>"↵
-ProtocolProfile WsFed-SAML -EncryptionCertificate "<CertificatePath>"
Discussion
When configuring AD FS, you’ll start by configuring one or more relying party trusts
to represent the organization that houses user accounts, which requires access to ap‐
plications hosted by one or more partners. The AD FS Federation Server in the partner’s
organization will create security tokens or claims that can be processed by the Federation
Service and used to make authorization decisions.
You can think of a relying party trust as being analogous to a trusted
domain or forest in an Active Directory trust relationship; however, it
is not necessary for an Active Directory trust relationship to be con‐
figured for AD FS to function in this manner.
In addition to configuring the relying party trust, you also need to determine which
types of claims will be sent by the account partner to the federation server hosted by the
partner. You can send any combination of UPN, E-Mail, Common name, Group, or
Custom claims. (Claim types are discussed further in Recipe 19.5.)
See Also
Recipe 19.5 for more on creating group or custom claims; Recipe 19.7 for information
on configuring a trust partner; Add-ADFSRelyingPartyTrust cmdlet reference
19.7. Configuring a Claims Provider Trust
Problem
You want to configure a claims provider trust to allow a partner organization to access
a resource in your environment.
Solution
Using a graphical user interface
1. Open the AD FS MMC snap-in (adfs.msc).
19.7. Configuring a Claims Provider Trust | 665
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
691
|
2. From the Actions menu, click Add Claims Provider Trust.
3. Click Start to begin the wizard.
4. To add a claims provider manually, click “Enter claims provider trust data man‐
ually” and then click Next.
5. Enter a display name and notes, and then click Next.
6. Select the appropriate AD FS profile and then click Next.
7. If necessary, select the additional protocols for the claims provider and then click
Next.
8. Enter the claims provider trust URI and then click Next.
9. Click Add to specify a token-signing certificate. Browse to the appropriate certifi‐
cate and click Open. Click Next to continue.
10. Click Next and then Close to complete the wizard.
Using Windows PowerShell
Add-ADFSClaimsProviderTrust -Name "<Name>" -MetadataUrl "<URI>"↵
-ProtocolProfile WsFed-SAML
Discussion
A claims provider trust is the necessary second piece of the AD FS puzzle, and is the
organization that is hosting the resources that need to be accessed by the account partner.
It’s important to note that claims provider trusts do not actually authenticate users from
the account partner’s organization; rather, they simply process the claims that are for‐
warded to them after the account partner has performed any necessary authentication.
This process cuts very much to the heart of AD FS—the resource partner trusts the
account partner to perform whatever authentication is needed, after which the claims
trust provider performs the authorization portion of the process using the claims that
were produced by the account partner.
See Also
Recipe 19.5 for more on configuring a claim; Recipe 19.6 for more on creating a party
trust; Add-ADFSClaimsProviderTrust cmdlet reference
19.8. Configuring an Alternate UPN Suffix
Problem
You want to modify or add a new UPN suffix for the users in an Active Directory forest.
666 | Chapter 19: Active Directory Federation Services
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
692
|
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 Active Directory Domains and Trusts and select
Properties.
3. Under Alternate UPN suffixes, type the name of the suffix you want to add.
4. Click Add and OK.
Using a command-line interface
> admod -config -rb cn=Partitions uPNSuffixes:+:treyresearch.com
The attributeName :+: attributeValue syntax will add an additional
value to an existing list of values in a multivalued attribute. Using at
tributeName::attributeValue would add the value you specify and
remove all other values.
Using PowerShell
Set-ADObject "cn=Partitions,cn=Configuration,<ForestRootDN>"↵
-Add @{"uPNSuffixes"="<Suffix>"}
Discussion
The UPN allows users to log on with a friendly name that may or may not correspond
to their email address. Also, UPN logons do not require the domain to be known, so it
can be abstracted away from the user. You may need to create an additional UPN suffix
(e.g., @adatum.com) if you want UPNs to map to email addresses when your AD forest
is rooted at a different domain name (e.g., ad.adatum.com) from the domain name used
in email addresses (e.g., adatum.com). In the case of AD FS, only one UPN claim can
be used for a given application, so it may also be necessary to configure additional UPN
suffixes to meet this requirement as well.
Using a command-line interface
Like many command-line recipes in this book, this recipe references the AdMod utility
that can be downloaded from joeware.
See Also
“HOW TO: Add UPN Suffixes to a Forest”
19.8. Configuring an Alternate UPN Suffix | 667
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
693
|
19.9. Configuring AD FS 2.x and AD FS 1.x Interoperability
Problem
You want to configure AD FS 2.x and AD FS 1.x interoperability for AD FS 1.x security
tokens.
Solution
Using a graphical user interface
The first step in configuring AD FS interoperability is to extract the User Principle Name
from Active Directory. To create a claim rule, follow these steps:
1. Launch the AD FS management console.
2. Expand AD FS→Trust Relationships→Claims Provider Trusts.
3. Right-click on the Claims Provider Trust you wish to configure and click Edit Claim
Rules.
4. On the Acceptance Transform Rules tab, click the Add Rule button.
5. On the Choose Rule Type screen, verify that Send LDAP Attributes as Claims is
selected from the drop-down box and then click Next.
6. From the Attribute Store drop-down box, select the appropriate attribute store.
7. From the LDAP Attribute drop-down box, select User-Principal-Name.
8. From the Outgoing Claim Type drop-down box, select UPN.
9. Name the claim rule appropriately and then click Finish.
The second step in configuring AD FS interoperability is to transform the claim to the
AD FS 1.x format, Name ID. To transform the claim, follow these steps:
1. Launch the AD FS management console.
2. Expand AD FS→Trust Relationships→Claims Provider Trusts.
3. Right-click on the Claims Provider Trust you wish to configure and click Edit Claim
Rules.
4. On the Acceptance Transform Rules tab, click the Add Rule button.
5. On the Choose Rule Type screen, select Transform an Incoming Claim.
6. From the Incoming claim type drop-down box, select UPN.
7. From the Outgoing claim type drop-down box, select Name ID.
8. From the name ID format drop-down box, select UPN.
668 | Chapter 19: Active Directory Federation Services
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
694
|
9. Verify that “Pass through all claim values” is selected.
10. Name the claim rule appropriately and then click Finish.
The third step in configuring AD FS interoperability is to extract the attribute store
information as AD FS 1.x claim types. To configure the claim rule, follow these steps:
1. Launch the AD FS management console.
2. Expand AD FS→Trust Relationships→Claims Provider Trusts.
3. Right-click on the Claims Provider Trust you wish to configure and click Edit Claim
Rules.
4. On the Acceptance Transform Rules tab, click the Add Rule button.
5. On the Choose Rule Type screen, verify that Send LDAP Attributes as Claims is
selected from the drop-down box and then click Next.
6. From the Attribute Store drop-down box, select the appropriate attribute store.
7. From the first LDAP Attribute drop-down box, select User-Principal-Name.
8. From the first Outgoing claim type drop-down box, select AD FS1.x UPN.
9. From the second LDAP Attribute drop-down box, select E-Mail-Addresses.
10. From the second Outgoing Claim Type drop-down box, select AD FS 1.x E-Mail
Addresses.
11. Name the claim rule appropriately and then click Finish.
The final step in configuring AD FS interoperability is to pass through the claim types
to the Relying Party Trust. Note that this claim rule is created on the Relying Party Trust.
To configure the claim rule, follow these steps:
1. Launch the AD FS management console.
2. Expand AD FS→Trust Relationships→Relying Party Trusts.
3. Right-click the relying party trust you wish to configure and click Edit Claim Rules.
4. On the Issuance Transform Rules tab, click Add Rule.
5. From the Claim rule template drop-down box, select Pass Through or Filter an
Incoming Claim.
6. From the Incoming claim type drop-down, select AD FS 1.x UPN.
7. Ensure that “Pass through all claim values” is selected.
8. Name the claim rule appropriately and then click Next.
9. Repeat these steps for the AD FS 1.x E-Mail Addresses claim type.
19.9. Configuring AD FS 2.x and AD FS 1.x Interoperability | 669
|
http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf
|
695
|
Using Windows PowerShell
To create the Claims Provider Trust rules using PowerShell, first create a text file named
CPTrust.txt with the following information:
@RuleTemplate = "LdapClaims"
@RuleName = "Extract UPN"
c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/↵
windowsaccountname", Issuer == "AD AUTHORITY"]
=> issue(store = "Active Directory", types =↵
("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"),↵
query = ";userPrincipalName;{0}", param = c.Value);
@RuleTemplate = "MapClaims"
@RuleName = "Transform UPN to Name ID"
c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"]
=> issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/↵
nameidentifier", Issuer = c.Issuer, OriginalIssuer = c.OriginalIssuer,↵
Value = c.Value, ValueType = c.ValueType, Properties[↵
"http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/format"]↵
= "http://schemas.xmlsoap.org/claims/UPN");
@RuleTemplate = "LdapClaims"
@RuleName = "Extract AD as 1.x"
c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/↵
windowsaccountname", Issuer == "AD AUTHORITY"]
=> issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/↵
claims/UPN", "http://schemas.xmlsoap.org/claims/EmailAddress"),↵
query = ";userPrincipalName,mail;{0}", param = c.Value);
After the text file has been created, append the current acceptance transform rules to
the file with the following commands:
$CPTrust = Get-ADFSClaimsProviderTrust
Add-Content C:\temp\CPTrust.txt $CPTrust.AcceptanceTransformRules
Failure to append the current acceptance transform rules to the file will
overwrite all existing transform rules for the party trust.
To set the claims provider trust with the claim rule sets, issue the following command:
Set-ADFSClaimsProviderTrust -TargetName "<CPTName>"↵
-AcceptanceTransformRulesFile "C:\temp\CPTrust.txt"
Next, to create the Relying Party Trust rules, create a text file named RPTrust.txt with
the following content:
@RuleTemplate = "PassThroughClaims"
@RuleName = "Pass through UPN"
c:[Type == "http://schemas.xmlsoap.org/claims/UPN"]
=> issue(claim = c);
670 | Chapter 19: Active Directory Federation Services
|
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.