1 Sub DeleteISAPIFilters(IISPath,dllPath)
\r
3 Dim filter, FiltersObj, LoadOrder, FilterArray, FilterItem
\r
5 Set FiltersObj = GetObject(IISPath & "/Filters")
\r
6 LoadOrder = FiltersObj.FilterLoadOrder
\r
8 for each filter in FiltersObj
\r
9 if (filter.Class = "IIsFilter") then
\r
10 if (filter.FilterPath = dllPath) then
\r
12 'Delete the found filter here
\r
13 'If there's anything to potentially delete...
\r
14 if (LoadOrder <> "") then
\r
15 FilterArray = split(LoadOrder,",")
\r
17 for each FilterItem in FilterArray
\r
18 if (FilterItem <> filter.Name) then
\r
19 LoadOrder = LoadOrder & FilterItem & ","
\r
22 'Remove trailing comma if any filters were kept
\r
23 if (LoadOrder <> "") then
\r
24 LoadOrder = mid(LoadOrder,1,len(LoadOrder)-1)
\r
27 'Set the Load Order to the new shibboleth-less order
\r
28 if (FiltersObj.FilterLoadOrder <> LoadOrder) then
\r
29 FiltersObj.FilterLoadOrder = LoadOrder
\r
34 'Delete the actual IISFilter object
\r
35 FiltersObj.Delete "IIsFilter",filter.Name
\r
44 Sub DeleteFileExtensions(siteObj, dllPath)
\r
46 Dim ScriptMaps, newScriptMaps
\r
47 Dim line, lineArray, lineIndex
\r
51 ScriptMaps = siteObj.ScriptMaps
\r
52 redim newScriptMaps(0)
\r
54 'copy each entry from the old ScriptMaps to newScriptMaps
\r
55 'unless it is for dllPath
\r
56 for each line in ScriptMaps
\r
57 lineArray = split(line,",")
\r
58 if (lineArray(1) <> dllPath) then
\r
59 redim preserve newScriptMaps(lineIndex)
\r
60 newScriptMaps(lineIndex) = line
\r
61 lineIndex = lineIndex + 1
\r
63 existsFlag = "exists"
\r
66 'If we found dllPath, then use the newScriptMaps instead
\r
67 if (existsFlag = "exists") then
\r
68 siteObj.ScriptMaps = newScriptMaps
\r
75 '*** Begin Main Code ***
\r
80 Dim site, siteObj, sitePath, LogFile
\r
82 ' First of all look for the FileExtension
\r
83 Set WshShell = CreateObject("WScript.Shell")
\r
85 'Get the INSTALLDIR value via CustomActionData
\r
86 InstallDir = Session.Property("CustomActionData")
\r
88 Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
\r
90 'Set LogFile = FileSystemObj.OpenTextFile(InstallDir & "\var\log\shibboleth\Installer.log", 8, true)
\r
92 On Error Resume Next
\r
93 regValue = WshShell.RegRead("HKLM\SOFTWARE\Shibboleth\FileExtension")
\r
97 ' LogFile.WriteLine "Uninstall IIS plugin - upgrade detected by uninstall script, skipping"
\r
99 ' Registry key is still there - this is an upgrade, so exit
\r
102 ' Key is gone - a pure uninstall
\r
104 ' LogFile.WriteLine "Uninstall IIS plugin"
\r
107 'Don't show errors, we'll handle anything important
\r
108 On Error Resume Next
\r
110 'Attempt to get W3SVC. If failure, end script (e.g. IIS isn't available)
\r
111 Set WebObj = GetObject("IIS://LocalHost/W3SVC")
\r
114 'Remove all trailing backslashes to normalize
\r
115 do while (mid(InstallDir,Len(InstallDir),1) = "\")
\r
116 InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
\r
118 ShibISAPIPath = InstallDir & "\lib\shibboleth\isapi_shib.dll"
\r
120 'Delete ISAPI Filter
\r
121 'First do the master service
\r
122 DeleteISAPIFilters "IIS://LocalHost/W3SVC",ShibISAPIPath
\r
123 'Now do the websites
\r
124 for each site in WebObj
\r
125 if (site.Class = "IIsWebServer") then
\r
126 sitePath = "IIS://LocalHost/W3SVC/" & site.Name
\r
127 DeleteISAPIFilters sitePath,ShibISAPIPath
\r
131 'Delete File Extensions
\r
132 'First do the master service
\r
133 DeleteFileExtensions WebObj,ShibISAPIPath
\r
134 'Now do the websites
\r
135 for each site in WebObj
\r
136 if (site.Class = "IIsWebServer") then
\r
137 set siteObj = GetObject("IIS://LocalHost/W3SVC/" & site.Name & "/ROOT")
\r
138 DeleteFileExtensions siteObj,ShibISAPIPath
\r
142 'Delete Web Services Extension (universal, no need to do for each site)
\r
143 WebObj.DeleteExtensionFileRecord ShibISAPIPath
\r
144 ' Got the IIS Object
\r
146 ' Sense whether this is an upgrade
\r