The Web Site property sheet, shown in Figure 9.1, allows you to manipulate the following:
Site description
IP address
TCP port
Host header name
Number of connections allowed
Logging options
All properties on this sheet can be manipulated using the ADSI IIS service provider.
The Web Site Identification frame shows all properties that affect how the site is described to clients or administrative tools. In this frame, you can manipulate the following:
ServerComment property or site description
IP address(es) used for the site
TCP port(s) used to access the site
Any host header information that uniquely identifies this site
In addition, you can define the IP address and TCP port used for Secure Sockets Layer (SSL) connections. Modifying these fields is an essential step toward establishing multiple sites on a single IIS server.
By manipulating the ServerComment field, you can examine and modify the description assigned to the Web site. As mentioned previously, this comment field is never used for programmatic identification; it is used solely to account for the fact that people are better at remembering names rather than integers.
To find the description assigned to the site, after binding to the appropriate site simply query the ServerComment property, as follows :
Dim Site As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Integer Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & Index) Debug.Print Site.ServerComment
To set a new server comment, simply assign the ServerComment property a new value, as follows:
Dim Site As IADs Dim ServerName As String Dim Index As Long Dim NewServerComment as String ServerName = "IIS_Server_Name" Index = Site_Index_Integer NewServerComment = "New_Server_Comment_String" Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & Index) Site.ServerComment = NewServerComment Site.SetInfo
As shown in Figure 9.2, IIS allows you the opportunity to publish multiple Web sites on a single IP address. To use multiple Web sites on the same machine you must do one of the following:
Use one IP address per site.
Use a unique TCP port for each site on the same IP address.
Use host headers to differentiate between each site on the same IP address.
Using ADSI, you can use the ServerBindings property to manipulate these parameters. The ServerBindings field is stored as an array of strings, with each string entered in the format IP_Address:TCP_Port:Hostname.
To find out on which TCP port or from which DNS entry a particular site will respond, use the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex) For Each Binding In Site.ServerBindings Debug.Print Binding Next
After formatting a string in the format IP_Address:TCP_Port:Hostname, you can create an array to change the way a site responds to an HTTP request. Use the following Visual Basic code as a guide to programmatically assign an alternate TCP port or host header to a bound site:
Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long Dim NewBindingArray as Variant Dim ServerBindingString1 as String Dim ServerBindingString2 as String Dim ServerBindingString3 as String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value ServerBindingString1 = "IP_Address:TCP_Port:Hostname" ServerBindingString2 = "IP_Address:TCP_Port:Hostname" ServerBindingString3 = "IP_Address:TCP_Port:Hostname" NewBindingArray = Array(ServerBindingString1, ServerBindingString2, ServerBindingString3) Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex) Site.ServerBindings = NewBindingArray Site.SetInfo
To set an IP address and TCP port for use with secure connections, you can manipulate the SecureBindings property. This property is nearly identical to the ServerBindings property. However, you cannot associate a host header with the site. This is not a limitation of IIS, but actually of host headers themselves . Over an SSL-encrypted connection, the host header is included in the encrypted request, making it impossible for the browser to decipher the host header. For this reason, only the IP address and TCP port are specified for SSL connections.
Although you cannot use host headers with SSL-protected sites, if you wish to create multiple identities for an SSL-protected site, you can use an alternate TCP port setting.
Note
For more information on host headers and SSL, check out the Microsoft Knowledge Base article Q187504. The Microsoft Knowledge Base can be found on Microsoft's home page, or through Microsoft TechNet or Microsoft MSDN .
To view the current configuration of your SSL-protected site, use the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex) For Each Binding In Site.SecureBindings Debug.Print Binding Next
After formatting a string as IP_Address:TCP_Port: , you can create an array to be assigned to the SecureBindings property using the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim SiteIndex As Long Dim NewBindingArray as Variant Dim ServerBindingString1 as String Dim ServerBindingString2 as String Dim ServerBindingString3 as String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value ServerBindingString1 = "IP_Address:TCP_Port:" ServerBindingString2 = "IP_Address:TCP_Port:" ServerBindingString3 = "IP_Address:TCP_Port:" NewBindingArray = Array(ServerBindingString1, ServerBindingString2, ServerBindingString3) Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex) Site.SecureBindings = NewBindingArray Site.SetInfo
In the Connections frame of IIS 4.0 Internet Service Manager's Web Site property sheet, you can specify the maximum number of connections to the site as well as define a timeout value for all connections. This can be very useful if used after determining your host's capacity with a product such as Microsoft Homer or another capacity planning tool. In addition, it is always a good idea to time out connections to the server to improve the likelihood that new users to the site will be able to obtain a connection.
Using the MaxConnections property of the IIsWebServer object, you can find the maximum number of simultaneous connections allowed to a particular site.
Note
Windows NT Workstation allows only 10 inbound connections. If you are using ADSI against a Personal Web Server (IIS on NT Workstation) the maximum number of connections will be 10 .
To view the maximum number of connections allowed to the bound Web site, use the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim Index As Long Dim RetVal as Long ServerName = "IIS_Server_Name" Index = Site_Index Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & Index) RetVal = Site.MaxConnections Debug.Print RetVal
Note
Unlike other ADSI properties, the MaxConnections property uses 2000000000 to designate an unlimited number of connections .
Use the following Visual Basic code to establish a new value for the maximum number of connections permitted to the bound Web site:
Dim Site As IADs Dim ServerName As String Dim Index As Long Dim NewMaxConnections as Long ServerName = "IIS_Server_Name" Index = Site_Index NewMaxConnections = Maximum_Number_of_Connections Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & Index) Site.MaxConnections = NewMaxConnections Site.SetInfo
Using the ConnectionTimeout property, you can specify the amount of time (in seconds) before a user 's HTTP connection is closed.
To find the number of seconds before an HTTP connection is closed, use the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim Index As Long Dim RetVal as Long ServerName = "IIS_Server_Name" Index = Site_Index Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & Index) RetVal = Site.ConnectionTimeout Debug.Print RetVal
To time out HTTP connections at a specified interval, use the following Visual Basic code:
Dim Site As IADs Dim ServerName As String Dim Index As Long Dim ConnectionTimeout as Long ServerName = "IIS_Server_Name" Index = Site_Index_Value NewConnectionTimeout = Connection_Timeout_in_Seconds Set Site = GetObject("IIS://" & ServerName & "/W3SVC/" & Index) Site.ConnectionTimeout = NewConnectionTimeout Site.SetInfo
IIS Logging
IIS logging is used in the WWW, FTP, SNMP, and NNTP services. To configure IIS logging for your Web site, consult Chapter 8, which covers programmatic administration of the IIS logging provider .
Top |