IIsWebService.CreateNewSite (ADSI)

The CreateNewSite method creates a new Web or FTP site. This method allows you to specify the site identification number that you want to use. If you do not specify a site identification number, the method performs a hash function on the ServerComment passed to the method and creates a new number.

Note

This method is only available on IIS 6.0 and later.

iActualSiteID = objIIsWebService.CreateNewSite(
  bstrServerComment As BSTR,
  pvServerBindings As VARIANT,
  bstrRootVDirPath As BSTR,
  vServerID As VARIANT
) As VARIANT

Parameters

  • bstrServerComment
    [in] String containing the ServerComment for the new Web site. In IIS Manager, this would be the Description field under Web Site Identification in a Web Site property sheet.

  • pvServerBindings
    [in] Pointer to a VARIANT containing an array of server binding strings specifying what server bindings you want on this site. Each server binding string includes at least one of the host name, port, or IP address. The string format is IP:Port:Hostname.

  • bstrRootVDirPath
    [in] String containing a fully qualified path to a physical directory to which you want the Web site mapped.

  • vServerID
    [in] VARIANT containing the site identification number which you want the method to use. If this parameter is empty, a hash function is used to create the site identification number.

Return Values

Returns the actual site identifier if the method succeeds.

If this method fails, it returns an error.

If a site already exists with the ServerComment that you want to use, an error is not returned because the new site can still be created with a unique site identification number.

Remarks

In the IIS metabase, sites are represented by the service type, and a unique site identification number. For example, on a new installation of IIS, the default Web site is represented in ADSI as w3svc/1.

In IIS versions 5.1 and earlier, the site identification number increases by one for each new site created. For example, if you create a Web site whose path is w3svc/3, the next site you create will become w3svc/4.

CreateNewSite allows you to specify the site identification number that you want to use. If you do not specify a site identification number, the method performs a hash function on the ServerComment passed to the method and creates a new number. If there are multiple sites with the same ServerComment, the hash function detects a collision and selects the next available site identification number. For example, create a site with the following line of code:

myNewSiteID = oIIsWebServiceObj.CreateNewSite("MyNewSite", Bindings, "C:\Inetpub\Wwwroot")

If there is already a Web site on the server called MyNewSite whose site identification number is 5555, then CreateNewSite will return 5556 if 5556 is not already taken.

If you create duplicate sites on multiple IIS 6.0 servers using the IIS Manager or the CreateNewSite method, there is a good chance that the site identification numbers will be the same on each server for each duplicated site. These servers can then be included in a Microsoft Application Center Web farm without problems.

Requirements

Server: Requires or Windows Server 2003.

Product: IIS

See Also