We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:
SUMMARY
Global and site-level Internet Server Application Programming Interface (ISAPI) filter information is stored in the Internet Information Server (IIS) metabase or the Internet Information Services (IIS) metabase. You can access the metabase programmatically through the IIS Admin Objects (IISAO), which uses Active Directory Service Interfaces (ADSI), or through the IIS Admin Base Object (IISABO), which uses Microsoft Visual C++ interfaces. This article describes how to add and remove ISAPI filters in IIS by using ADSI.
Note The sample code in this article must be run with the security context of a member of the local Administrators group on the IIS server.
Remove an ISAPI filter by using ADSI
The following sample code removes a global filter named "myFilter" from the ISAPI filters list on the master properties of the WWW Publishing service.
Dim objFilterProps, objFilters
Dim strLoadOrder
Dim strFilterName
Dim intStartFilt
strFilterName = "myFilter"
Set objFilters = GetObject("IIS://LocalHost/W3SVC/Filters")
strLoadOrder = objFilters.FilterLoadOrder
If strLoadOrder <> "" Then
If Right(strLoadOrder, 1) <> "," Then
strLoadOrder = strLoadOrder & ","
End If
intStartFilt = InStr(strLoadOrder, strFilterName)
strLoadOrder = Mid(strLoadOrder, 1, intStartFilt - 1) & _
Mid(strLoadOrder, intStartFilt + Len(strFilterName) + 1, _
Len(strLoadOrder))
objFilters.FilterLoadOrder= strLoadOrder
objFilters.SetInfo
objFilters.Delete "IIsFilter", strFilterName
End If
Set objFilters = Nothing
Note that to remove the ISAPI filter from memory, you must restart IISADMIN service.
Troubleshooting
The example that is provided in this article demonstrates how to add and remove global ISAPI filters. To add or remove site-level ISAPI filters, use
GetObject("IIS://LocalHost/W3SVC/1/Filters")
to reference the correct metabase node, instead of the
GetObject("IIS://LocalHost/W3SVC/Filters")
example that is used in this article. The "1" in "/W3SVC/1/" refers to the metabase site instance ID of the particular Web site (in this case, the default Web site).
REFERENCES
For more information about how to manually add an ISAPI filter into IIS, click the following article number to view the article in the Microsoft Knowledge Base:
150312
How to install an ISAPI filter dynamic-link library