Delete(String, Boolean) Method
The Delete method of the SPSiteCollection class deletes the SPSite object with the specified server-relative URL from the collection and removes the site collection users from the Active Directory directory service if bDeleteADAccounts is true. This method is only intended for use in Active Directory account creation mode.
strSiteUrl A string that contains the server-relative URL of the site object to delete (for example, Site_Name or sites/Site_Name).
bDeleteADAccounts true to remove the site collection users from the Active Directory directory service; otherwise, false.
To delete a site collection from a virtual server requires security validation that uses the AdminFormDigest property of the SPGlobalAdmin class to insert a message digest on the page in the browser. This can be done by registering the digest as a hidden field through the RegisterHiddenField method of the System.Web.UI.Page class. In addition, use the RequestFromAdminPort field of the SPGlobalAdmin class to specify that the context of the request is through the administrative port.
The following code example deletes a top-level site from the site collection of a specified virtual server and removes its users from the Active Directory directory service.
Platforms: Microsoft Windows Server 2003
Security: Code Access Security