Delete an application partition (VBScript)
This code can be found in
Chapter 18 of Active Directory Cookbook, 2nd edition
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' This VBScript code deletes the specified application partition
' ---------------------------------------------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' ISBN: 0-596-00466-4
' ---------------------------------------------------------------
' ------ SCRIPT CONFIGURATION ------
strAppPart = "<AppPartitionDN>" ' DN of the app partition to delete
' ------ END CONFIGURATION ---------
set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://cn=Partitions," & objRootDSE.Get("ConfigurationNamingContext") & ">;"
strFilter = "(&(objectclass=crossRef)(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
else
objRS.MoveLast
set objAppPart = GetObject("LDAP://" & _
objRS.Fields("distinguishedName").Value )
objAppPart.DeleteObject(0)
Wscript.Echo "Deleted " & objRS.Fields("distinguishedName").Value
end if
|
This code has been viewed 2766 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|