IIsFtpService.CreateNewSite (WMI)

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.

strPath = objIIsFtpService.CreateNewSite(
      ServerComment,
      ServerBindings[],
      PathOfRootVirtualDir,
      ServerId
)

Parameters

  • ServerComment
    [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.

  • ServerBindings[]
    [in] An array of ServerBinding (WMI) objects specifying what server bindings you want on this site. Each server binding includes at least one of the host name, port, or IP address.

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

  • ServerId
    [in, optional] Long integer 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 a string containing the metabase path to the new FTP site.

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 FTP site is represented in ADSI as msftpsvc/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 FTP site whose path is msftpsvc/3, the next site you create will become msftpsvc/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 = objIIsFtpService.CreateNewSite("MyNewSite", Bindings, "C:\Inetpub\Wwwroot")

If there is already a FTP 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