Directory Services

Deleting an ADAM Application Directory Partition

[This documentation is preliminary and subject to change.]

To delete an application directory partition from ADAM, bind to an ADAM instance, search the Partitions container for the cross reference to the specified partition, bind to the parent of the cross reference, and delete the cross reference for the partiton from the ADAM instance.

You can create an application directory partition when you install ADAM, or you can create one later by Creating an ADAM Application Directory Partition.

The following VBScript code example binds to the Root DSE object of an ADAM instance, uses ActiveX Database Objects to search the Partitions container for a crossRef object with a nCName attribute that matches the distinguished name of the specified partition to delete. Deleting this crossRef object, which represents the partition, deletes the specified partition.

' Delete ADAM Application Directory Partition.

' Search Partitions container for crossRef object with nCName
' that matches the distinguished name of a specified partition.
' Delete this crossRef object, that represents the partition.

Option Explicit

Dim objCommand	 ' Query command object.
Dim objConnection	' Query connection object.
Dim objCrossRef	' crossRef object.
Dim objField		 ' Query field result.
Dim objParent		' Parent of crossRef object (ADP).
Dim objResults	 ' Results of query.
Dim objRootDSE	 ' Root DSE object of instance.
Dim strADP		 ' Partition name to delete.
Dim strCommand	 ' Command to run.
Dim strCrossRefPath  ' crossRef result.
Dim strnCName		' Name of crossRef result.
Dim strPartitions	' Partitions naming context.
Dim strPath		' Binding path.

' Construct ADAMsPath binding string.
' Change "localhost" to appropriate server.
' Change "389" to port for appropriate instance.
strPath = "LDAP://localhost:389"

WScript.Echo "Bind to: " & strPath

' Specify application directory partition.
' Change "O=Fabrikam,C=US" to appropriate partition.
strADP = "O=Fabrikam,C=US"

WScript.Echo "Delete:  Partition " & strADP

' Bind to RootDSE.
Set objRootDSE = GetObject(strPath & "/RootDSE")

' Get configurationNamingContext property.
strPartitions = "CN=Partitions," & _

' Set up query connection.
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"

' Set up query command.
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
strCommand = "<" & strPath & "/" & strPartitions & _
				">;(&(objectClass=crossRef)(nCName=" & strADP & _
objCommand.CommandText = strCommand

' Execute query.
Set objResults = objCommand.Execute

' Get first result, which should be the only result.
Set objField = objResults(0)

' Construct path to crossRef object.
strCrossRefPath = strPath & "/CN=" & objField.Value & "," & strPartitions

' Bind to crossRef object.
Set objCrossRef = GetObject(strCrossRefPath)
strnCName = objCrossRef.nCName

' Bind to parent of crossRef (APD) object.
Set objParent = GetObject(objCrossRef.Parent)

' Delete crossRef (APD) object.
objParent.Delete "crossRef", objCrossRef.Name

WScript.Echo "Success: Deleted " & strCrossRefPath
WScript.Echo "		 Partition " & strnCName