Programmatically Administering the Documents Property Sheet

   

Programmatically Administering the Documents Property Sheet

If a document name is not specified on the URL, IIS can be configured to automatically determine the intended document, as shown in Figure 9.11.

Figure 9.11. Default Web Site Properties Configuration dialog boxDocuments tab.

graphics/09fig11.gif

In addition, you can configure IIS to attach an HTML footer to all documents transferred from your Web server to the client browser. This can be especially handy for navigation bars, copyright notices, or other legal information.

Enable Default Document

To save the user from having to know the main document for your site, you can specify the name of the document to be returned to the client when the filename is omitted from the URL.

To enable this functionality, two properties must be configured: EnableDefaultDoc and DefaultDoc . EnableDefaultDoc is a Boolean value describing whether the default document list should be checked or not. DefaultDoc is a comma-delimited list stored as a string (not in a variant array) that lists the names of documents that will be sought when the user does not specify a filename in the URL. Together, these two properties allow the user to enter a site without typing or even knowing the particular filename.

Querying EnableDefaultDoc Using Visual Basic

To find if a default document is in use for a specific site, use the following Visual Basic code:

 Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.EnableDefaultDoc 
Setting EnableDefaultDoc Using Visual Basic

To set a new value for EnableDefaultDoc , use the following Visual Basic code:

 Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim EnableDefaultDocument As Boolean ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value EnableDefaultDocument = True Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.EnableDefaultDoc = EnableDefaultDocument Resource.SetInfo 
Querying DefaultDoc Using Visual Basic

To find the default documents used for a particular site, use the following Visual Basic code to return a comma-delimited list of files:

 Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.DefaultDoc 
Setting DefaultDoc Using Visual Basic

To set a new default document for a site, use the following Visual Basic code to pass in a comma-delimited list of documents. The order is important in the list; it determines the order in which IIS will look for the default document if more than one file in the list exists in the file system directory.

 Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim DefaultDocument As String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value DefaultDocument = "default.asp,default.htm,index.html" Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.DefaultDoc = DefaultDocument Resource.SetInfo 

Enable Document Footer

The document footer allows the administrator to attach an HTML-format file to all outbound HTML files from the server. This can be especially handy for navigation tool bars, legal notices, or even contact information. Unlike the DefaultDoc list, only a single file is used, and the full physical path to the file is specified in the DefaultDocFooter property.

After the DefaultDocFooter property populates the path to the HTML file, you can enable the footer by setting the EnableDocFooter property to True.

Querying DefaultDocFooter Using Visual Basic

To find the name of the HTML file attached to all HTML page requests , use the following Visual Basic code:

 Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.DefaultDocFooter 
Setting DefaultDocFooter Using Visual Basic

To establish a default document footer for a site, use the following Visual Basic code:

 Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim DefaultDocumentFooter As String ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value DefaultDocumentFooter = "c:\legal_footers\copyright.htm" Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.DefaultDocFooter = DefaultDocumentFooter Resource.SetInfo 
Querying EnableDocFooter Using Visual Basic

To query whether or not the document footer is enabled for a site, use the following Visual Basic code to return a Boolean value representing the status of the property:

 Dim Resource As IADs Dim ServerName As String Dim Index As Long ServerName = "IIS_Server_Name" Index = Site_Index_Value Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & Index & "/ROOT") Debug.Print Resource.EnableDocFooter 
Setting EnableDocFooter Using Visual Basic

After establishing the name of the HTML file to be used, you must enable the use of the document footer by setting the EnableDocFooter to True if you want to attach a footer to HTML page requests. Use the following Visual Basic code to perform this task:

 Dim Resource As IADs Dim ServerName As String Dim SiteIndex As Long Dim EnableDocumentFooter As Boolean ServerName = "IIS_Server_Name" SiteIndex = Site_Index_Value EnableDocumentFooter = True Set Resource = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT") Resource.EnableDocFooter = EnableDocumentFooter Resource.SetInfo 

   
Top


Windows NT. 2000 ADSI Scripting for System Administration
Windows NT/2000 ADSI Scripting for System Administration
ISBN: 1578702194
EAN: 2147483647
Year: 2000
Pages: 194
Authors: Thomas Eck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net