--- /dev/null
+Sub DeleteISAPIFilters(IISPath,dllPath)\r
+\r
+ Dim filter, FiltersObj, LoadOrder, FilterArray, FilterItem\r
+\r
+ Set FiltersObj = GetObject(IISPath & "/Filters")\r
+ LoadOrder = FiltersObj.FilterLoadOrder\r
+\r
+ for each filter in FiltersObj\r
+ if (filter.Class = "IIsFilter") then\r
+ if (filter.FilterPath = dllPath) then\r
+\r
+ 'Delete the found filter here\r
+ 'If there's anything to potentially delete...\r
+ if (LoadOrder <> "") then\r
+ FilterArray = split(LoadOrder,",")\r
+ LoadOrder = ""\r
+ for each FilterItem in FilterArray\r
+ if (FilterItem <> filter.Name) then\r
+ LoadOrder = LoadOrder & FilterItem & ","\r
+ end if\r
+ next\r
+ 'Remove trailing comma if any filters were kept\r
+ if (LoadOrder <> "") then\r
+ LoadOrder = mid(LoadOrder,1,len(LoadOrder)-1)\r
+ end if\r
+\r
+ 'Set the Load Order to the new shibboleth-less order\r
+ if (FiltersObj.FilterLoadOrder <> LoadOrder) then\r
+ FiltersObj.FilterLoadOrder = LoadOrder\r
+ FiltersObj.SetInfo\r
+ end if\r
+ end if\r
+\r
+ 'Delete the actual IISFilter object\r
+ FiltersObj.Delete "IIsFilter",filter.Name\r
+\r
+ end if\r
+ end if\r
+ next\r
+\r
+End Sub\r
+\r
+\r
+Sub DeleteFileExtensions(siteObj, dllPath)\r
+\r
+Dim ScriptMaps, newScriptMaps\r
+Dim line, lineArray, lineIndex\r
+Dim fileExtension\r
+Dim existsFlag\r
+\r
+ ScriptMaps = siteObj.ScriptMaps\r
+ redim newScriptMaps(0)\r
+ lineIndex = 0\r
+ 'copy each entry from the old ScriptMaps to newScriptMaps\r
+ 'unless it is for dllPath\r
+ for each line in ScriptMaps\r
+ lineArray = split(line,",")\r
+ if (lineArray(1) <> dllPath) then\r
+ redim preserve newScriptMaps(lineIndex)\r
+ newScriptMaps(lineIndex) = line\r
+ lineIndex = lineIndex + 1\r
+ else\r
+ existsFlag = "exists"\r
+ end if\r
+ next\r
+ 'If we found dllPath, then use the newScriptMaps instead\r
+ if (existsFlag = "exists") then\r
+ siteObj.ScriptMaps = newScriptMaps\r
+ siteObj.SetInfo\r
+ end if\r
+\r
+End Sub\r
+\r
+\r
+'*** Begin Main Code ***\r
+Dim WebObj\r
+Dim InstallDir\r
+Dim FileSystemObj\r
+Dim ShibISAPIPath\r
+Dim site, siteObj, sitePath, LogFile\r
+\r
+' First of all look for the FileExtension\r
+Set WshShell = CreateObject("WScript.Shell")\r
+\r
+'Get the INSTALLDIR value via CustomActionData\r
+InstallDir = Session.Property("CustomActionData")\r
+\r
+Set FileSystemObj = CreateObject("Scripting.FileSystemObject")\r
+\r
+'Set LogFile = FileSystemObj.OpenTextFile(InstallDir & "\var\log\shibboleth\Installer.log", 8, true)\r
+\r
+On Error Resume Next\r
+regValue = WshShell.RegRead("HKLM\SOFTWARE\Shibboleth\FileExtension")\r
+if (Err = 0) then\r
+\r
+ ' If (LogFile) then\r
+ ' LogFile.WriteLine "Uninstall IIS plugin - upgrade detected by uninstall script, skipping"\r
+ 'End If\r
+ ' Registry key is still there - this is an upgrade, so exit\r
+\r
+else \r
+ ' Key is gone - a pure uninstall\r
+ 'If (LogFile) then\r
+ ' LogFile.WriteLine "Uninstall IIS plugin"\r
+ 'End If\r
+ \r
+ 'Don't show errors, we'll handle anything important\r
+ On Error Resume Next\r
+\r
+ 'Attempt to get W3SVC. If failure, end script (e.g. IIS isn't available)\r
+ Set WebObj = GetObject("IIS://LocalHost/W3SVC")\r
+ if (Err = 0) then\r
+\r
+ 'Remove all trailing backslashes to normalize\r
+ do while (mid(InstallDir,Len(InstallDir),1) = "\")\r
+ InstallDir = mid(InstallDir,1,Len(InstallDir)-1)\r
+ loop\r
+ ShibISAPIPath = InstallDir & "\lib\shibboleth\isapi_shib.dll"\r
+\r
+ 'Delete ISAPI Filter\r
+ 'First do the master service\r
+ DeleteISAPIFilters "IIS://LocalHost/W3SVC",ShibISAPIPath\r
+ 'Now do the websites\r
+ for each site in WebObj\r
+ if (site.Class = "IIsWebServer") then\r
+ sitePath = "IIS://LocalHost/W3SVC/" & site.Name\r
+ DeleteISAPIFilters sitePath,ShibISAPIPath\r
+ end if\r
+ next\r
+\r
+ 'Delete File Extensions\r
+ 'First do the master service\r
+ DeleteFileExtensions WebObj,ShibISAPIPath\r
+ 'Now do the websites\r
+ for each site in WebObj\r
+ if (site.Class = "IIsWebServer") then\r
+ set siteObj = GetObject("IIS://LocalHost/W3SVC/" & site.Name & "/ROOT")\r
+ DeleteFileExtensions siteObj,ShibISAPIPath\r
+ end if\r
+ next\r
+\r
+ 'Delete Web Services Extension (universal, no need to do for each site)\r
+ WebObj.DeleteExtensionFileRecord ShibISAPIPath\r
+ ' Got the IIS Object\r
+ End If\r
+' Sense whether this is an upgrade\r
+end if
\ No newline at end of file