Deleting a Subnet
You want to delete a subnet object.
Using a graphical user interface
Using a command-line interface
You can delete a subnet object using the built-in dsrm utility or AdMod. The dsrm utility takes the following syntax:
> dsrm cn=<SubnetName>,cn=subnets,cn=sites,cn=configuration,<ForestRootDN>
To remove a subnet using AdMod, use this syntax:
> admod b cn=<SubnetName>,cn=subnets,cn=sites,cn=configuration,<ForestRootDN> -del\
strSubnetName = "cn=<SubnetName>" ' e.g. "cn=10.0.0.0/8" strParentDN = cn=subnets,cn=sites,cn=configuration," _ & strForestDN strForestDN = "<ForestRootDN>" ' e.g. "dc=rallencorp,dc=com" set objContainer = GetObject("LDAP://" & strParentDN) objContainer.Delete "subnet", strSubnetName
This script example uses the IADsContainer::Delete method to delete the subnet object. To use this method, you must first bind to the parent container of the object. You then call Delete by passing the object class along with the RDN of the object that you want to delete.
The Delete method is a safer alternative to the DeleteObject method because you need to be more explicit about what you are deleting. With DeleteObject, you only have to specify the distinguished name of an object and it will summarily delete it. For example, the following code will delete a subnet object using DeleteObject:
strSubnetDN = "<SubnetDN>" set objSubnet = GetObject("LDAP://" & strObjectDN) objSubnet.DeleteObject(0)
As you can see, if a user accidentally or maliciously mistypes an inappropriate DN, the result could be disastrous. Using the DeleteObject method puts more constraints on the delete operation.
Recipe 4.25 for deleting a container object, MS KB 258310 (Viewing Deleted Objects in Active Directory), MSDN: IADsContainer::Delete, and MSDN: IADsDeleteOps:: DeleteObject