Help and Support
 

powered byLive Search

How to programmatically add or remove an ISAPI filter in IIS by using ADSI

Article ID:302988
Last Review:July 7, 2008
Revision:4.1
This article was previously published under Q302988
We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 7.0 running on Microsoft Windows Server 2008. IIS 7.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:
http://www.microsoft.com/technet/security/prodtech/IIS.mspx (http://www.microsoft.com/technet/security/prodtech/IIS.mspx)
For more information about IIS 7.0, visit the following Microsoft Web site:
http://www.iis.net/default.aspx?tabid=1 (http://www.iis.net/default.aspx?tabid=1)
On This Page

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.

Back to the top

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.

Back to the top

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).

Back to the top

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 (http://support.microsoft.com/kb/150312/) How to install an ISAPI filter dynamic-link library

Back to the top


APPLIES TO
Microsoft Internet Information Services version 5.1
Microsoft Internet Information Server 4.0

Back to the top

Keywords: 
kbhowtomaster KB302988

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.