Recipe 17.1 Creating and Deleting an Application Partition

17.1.1 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 only replicate the data to the domain controllers of your choosing.

17.1.2 Solution Using a graphical user interface

To create an application partition, do the following:

  1. Open ADSI Edit.

  2. Connect to the domain of which the new application partition will be a child.

  3. In the left pane, right-click on the domain and select New Object.

  4. Select domainDNS and click Next.

  5. For Value, enter the name of the application partition and click Next.

  6. Click on More Attributes.

  7. Select Both for which properties to view.

  8. Select instanceType for property to view.

  9. For the Edit Attribute field, enter 5.

  10. Click the Set button.

  11. Click OK.

  12. Click Finish.

To delete an application, do the following:

  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 Delete.

  5. Click Yes to confirm. Using a command-line interface

Use the following command to create an application partition on a domain controller:

> ntdsutil "dom man" conn "co to se <DomainControllerName>" q "create nc[RETURN]
<AppPartitionDN> NULL" q q

Use the following command to delete an application partition:

> ntdsutil "dom man" conn "co to se <DomainControllerName>" q "delete nc[RETURN]
<AppPartitionFQDN>" q q Using VBScript
' This code creates an application partition off of the 
' root of the default forest.
strAppPart = "<AppPartitionName>" ' DN of the app partition to delete
strServer  = "<DomainControllerName>" ' DNS name of DC to host app partition
strDescr   = "<Description>"  ' Descriptive text about the app partition
' ------ END CONFIGURATION ---------

set objRootDSE = GetObject("LDAP://" & strServer & "/RootDSE")
set objLDAP = GetObject("LDAP://" & strServer & "/" & _
                        objRootDSE.Get("rootDomainNamingContext") )
set objAppPart = objLDAP.Create("domainDNS", "dc=" & strAppPart)
objAppPart.Put "instancetype", 5
objAppPart.Put "description", strDescr
WScript.Echo "Created application partition: " & strAppPart
' This code deletes the specified application partition
strAppPart = "<AppPartitionDN>"  ' DN of the app partition to delete
' ------ END CONFIGURATION ---------

set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://cn=Partitions," & _
           objRootDSE.Get("ConfigurationNamingContext") & ">;"
strFilter  = "(&(objectcategory=crossRef)(nCName=" & _
             strAppPart & "));" 
strAttrs   = "cn,distinguishedName;"
strScope   = "onelevel"

set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)

if objRS.RecordCount <> 1 then
   WScript.Echo "Did not find a match for " & strAppPart
   set objAppPart = GetObject("LDAP://" & _
                              objRS.Fields("distinguishedName").Value )
   Wscript.Echo "Deleted " & objRS.Fields("distinguishedName").Value
end if

17.1.3 Discussion

To create an application partition, you need to create a domainDNS object that serves as the root container for the partition. A crossRef object is automatically created in the Partitions container in the CNC. Conversely, when removing an application partition, you only need to remove the crossRef object and the domainDNS is automatically 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.

17.1.4 See Also

MS KB 322669 (HOW TO: Manage the Application Directory Partition and Replicas in Windows Server 2003), and MSDN: Creating an Application Directory Partition, and MSDN: Deleting an Application Directory Partition

    Chapter 3. Domain Controllers, Global Catalogs, and FSMOs
    Chapter 6. Users
    Appendix A. Tool List