+++ /dev/null
-Function ReadFile( filePath )\r
- Dim theFile\r
-\r
- 'OpenTextFile args: <path>, 1 = ForReading\r
- 'If you read an empty file, VBScript throws an error for some reason\r
- if (FileSystemObj.FileExists(filePath)) then\r
- Set theFile = FileSystemObj.GetFile(filePath)\r
- if (theFile.size > 0) then\r
- Set theFile = FileSystemObj.OpenTextFile(filePath, 1)\r
- ReadFile = theFile.ReadAll\r
- else\r
- ReadFile = ""\r
- end if\r
- else\r
- ReadFile = ""\r
- end if\r
-End Function\r
-\r
-Sub WriteFile( filePath, contents )\r
- Dim theFile\r
-\r
- 'OpenTextFile args: <path>, 2 = ForWriting, True = create if not exist\r
- Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True)\r
- theFile.Write contents\r
-End Sub\r
-\r
-Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )\r
- Dim buffer\r
-\r
- buffer = ReadFile(filePath)\r
- if (buffer <> "") then\r
- buffer = Replace(buffer, lookForStr, replaceWithStr)\r
- WriteFile filePath, buffer\r
- end if\r
-End Sub\r
-\r
-\r
-Dim FileSystemObj, ConfigFile, ConfigFileName, XMLDir, WshShell\r
-\r
-on error resume next\r
-Set FileSystemObj = CreateObject("Scripting.FileSystemObject")\r
-if (Err = 0) then\r
-\r
- 'Get the parameters via CustomActionData\r
- customData = Session.Property("CustomActionData")\r
- msiProperties = split(customData,";@;")\r
- XMLDir = msiProperties(0) ' \programdata\shibboleth\sp\xml\opensaml\\r
- ConfigFile = msiProperties(1) 'catalog\r
-\r
- ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir\r
-\r
-'Last End If\r
-End If
\ No newline at end of file
+++ /dev/null
-Dim FiltersObj
-Dim FilterObj
-Dim LoadOrder
-Dim FilterName
-Dim FilterPath
-Dim FilterDesc
-Dim WebObj, WebSite, WebSiteRoot
-Dim existsFlag
-Dim ScriptMaps
-Dim newScriptLine
-Dim line, lineArray, lineIndex
-Dim WebSvcExts
-Dim newWebSvcExtLine
-Dim customData, msiProperties, InstallDir, ShibFileExtension
-
-On Error Resume Next
-Set WebObj = GetObject("IIS://LocalHost/W3SVC")
-if (Err = 0) then
-
- 'Get the INSTALLDIR and SHIB_FILE_EXTENSION values via CustomActionData
- customData = Session.Property("CustomActionData")
- msiProperties = split(customData,";@;")
- InstallDir = msiProperties(0)
- ShibFileExtension = msiProperties(1)
-
- 'Remove all trailing backslashes to normalize
- do while (mid(InstallDir,Len(InstallDir),1) = "\")
- InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
- loop
- ShibISAPIPath = InstallDir & "\lib\shibboleth\isapi_shib.dll"
- 'Make sure ShibFileExtension is in proper format
- 'First, strip any preceding periods
- do while (mid(ShibFileExtension,1,1) = ".")
- ShibFileExtension = mid(ShibFileExtension,2,Len(ShibFileExtension)-1)
- loop
- 'If there is nothing left (or was nothing to begin with), use the default
- if (ShibFileExtension = "") then
- ShibFileExtension = ".sso"
- else
- 'Add preceding period
- ShibFileExtension = "." & ShibFileExtension
- end if
-
- 'Specify other ISAPI Filter details
- FilterName = "Shibboleth"
- FilterPath = ShibISAPIPath
- FilterDesc = ""
-
- Set FiltersObj = GetObject("IIS://LocalHost/W3SVC/Filters")
- LoadOrder = FiltersObj.FilterLoadOrder
- 'Check to see if 'Shibboleth' is already sequenced
- existsFlag = "not_exist"
- lineArray = split(LoadOrder, ",")
- for each line in lineArray
- if (line = FilterName) then
- existsFlag = "exists"
- end if
- next
- if (existsFlag = "not_exist") then
- If LoadOrder <> "" Then
- LoadOrder = LoadOrder & ","
- End If
- LoadOrder = LoadOrder & FilterName
- FiltersObj.FilterLoadOrder = LoadOrder
- FiltersObj.SetInfo
- else
- 'msgbox "Shib Filter already sequenced"
- end if
-
- Set FilterObj = FiltersObj.Create("IIsFilter", FilterName)
- If (Err <> 0) then
- 'Open existing filter for updating
- Err = 0
- Set FilterObj = GetObject("IIS://LocalHost/W3SVC/Filters/" & FilterName)
- End If
- FilterObj.FilterPath = FilterPath
- FilterObj.FilterDescription = FilterDesc
- FilterObj.SetInfo
-
- 'Create file extension mapping to ISAPI filter
- newScriptLine = ShibFileExtension & "," & ShibISAPIPath & ",1"
- ScriptMaps = WebObj.ScriptMaps
- 'Check if exists
- existsFlag = "not_exist"
- lineIndex = 0
- for each line in ScriptMaps
- lineArray = split(line,",")
- if (lineArray(0) = ShibFileExtension) then
- existsFlag = "exists"
- Exit For
- end if
- lineIndex = lineIndex + 1
- next
- if (existsFlag = "not_exist") then
- redim preserve ScriptMaps(UBound(ScriptMaps)+1)
- ScriptMaps(UBound(ScriptMaps)) = newScriptLine
- WebObj.ScriptMaps = ScriptMaps
- WebObj.SetInfo
- else
- 'msgbox ".sso already exists: " & lineIndex
- 'We already warned user in dialog that this value would be updated
- ScriptMaps(lineIndex) = newScriptLine
- WebObj.ScriptMaps = ScriptMaps
- WebObj.SetInfo
- end if
-
- 'Create file extension mapping to filter on each web site root
- For Each WebSite in WebObj
- Set WebSiteRoot = GetObject(WebSite.ADsPath & "/ROOT")
- if (Err = 0) then
- ScriptMaps = WebSiteRoot.ScriptMaps
- 'Check if exists
- existsFlag = "not_exist"
- lineIndex = 0
- for each line in ScriptMaps
- lineArray = split(line,",")
- if (lineArray(0) = ShibFileExtension) then
- existsFlag = "exists"
- Exit For
- end if
- lineIndex = lineIndex + 1
- next
- if (existsFlag = "not_exist") then
- redim preserve ScriptMaps(UBound(ScriptMaps)+1)
- ScriptMaps(UBound(ScriptMaps)) = newScriptLine
- WebSiteRoot.ScriptMaps = ScriptMaps
- WebSiteRoot.SetInfo
- else
- 'msgbox ".sso already exists: " & lineIndex
- 'We already warned user in dialog that this value would be updated
- ScriptMaps(lineIndex) = newScriptLine
- WebSiteRoot.ScriptMaps = ScriptMaps
- WebSiteRoot.SetInfo
- end if
- End If
- Next
-
-
- 'Web Services Extension
- Err = 0
- WebSvcExts = WebObj.WebSvcExtRestrictionList
- if (Err = 0) then
- newWebSvcExtLine = "1," & ShibISAPIPath & ",1,ShibGroup,Shibboleth Web Service Extension"
-
- existsFlag = "not_exist"
- lineIndex = 0
- for each line in WebSvcExts
- lineArray = split(line,",")
- if (lineArray(1) = ShibISAPIPath) then
- existsFlag = "exists"
- Exit For
- end if
- lineIndex = lineIndex + 1
- next
-
- if (existsFlag = "not_exist") then
- redim preserve WebSvcExts(UBound(WebSvcExts)+1)
- WebSvcExts(UBound(WebSVCExts)) = newWebSvcExtLine
- WebObj.WebSvcExtRestrictionList = WebSvcExts
- WebObj.SetInfo
- else
- 'msgbox "Shibboleth Web Services Extension already exists: " & lineIndex
- 'We already warned user in dialog that this value would be updated
- WebSvcExts(lineIndex) = newWebSvcExtLine
- WebObj.WebSvcExtRestrictionList = WebSvcExts
- WebObj.SetInfo
- end if
-
- end if
-
-'final end if
-end if
\ No newline at end of file
+++ /dev/null
-Dim ConvertedDir, InstallDir, ScriptName, WshShell\r
-\r
-On Error Resume Next\r
-Set WshShell = CreateObject("WScript.Shell")\r
-If (Err = 0) then\r
- 'Get the INSTALLDIR value via CustomActionData\r
- InstallDir = Session.Property("CustomActionData")\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
- ConvertedDir = Replace(InstallDir, "\", "/")\r
- ScriptName = ConvertedDir & "\etc\shibboleth\keygen.bat"\r
- \r
- WshShell.Exec(ScriptName)\r
-End If\r
+++ /dev/null
-Sub DeleteISAPIFilters(IISPath,dllPath)
-
- Dim filter, FiltersObj, LoadOrder, FilterArray, FilterItem
-
- Set FiltersObj = GetObject(IISPath & "/Filters")
- LoadOrder = FiltersObj.FilterLoadOrder
-
- for each filter in FiltersObj
- if (filter.Class = "IIsFilter") then
- if (filter.FilterPath = dllPath) then
-
- 'Delete the found filter here
- 'If there's anything to potentially delete...
- if (LoadOrder <> "") then
- FilterArray = split(LoadOrder,",")
- LoadOrder = ""
- for each FilterItem in FilterArray
- if (FilterItem <> filter.Name) then
- LoadOrder = LoadOrder & FilterItem & ","
- end if
- next
- 'Remove trailing comma if any filters were kept
- if (LoadOrder <> "") then
- LoadOrder = mid(LoadOrder,1,len(LoadOrder)-1)
- end if
-
- 'Set the Load Order to the new shibboleth-less order
- if (FiltersObj.FilterLoadOrder <> LoadOrder) then
- FiltersObj.FilterLoadOrder = LoadOrder
- FiltersObj.SetInfo
- end if
- end if
-
- 'Delete the actual IISFilter object
- FiltersObj.Delete "IIsFilter",filter.Name
-
- end if
- end if
- next
-
-End Sub
-
-
-Sub DeleteFileExtensions(siteObj, dllPath)
-
-Dim ScriptMaps, newScriptMaps
-Dim line, lineArray, lineIndex
-Dim fileExtension
-Dim existsFlag
-
- ScriptMaps = siteObj.ScriptMaps
- redim newScriptMaps(0)
- lineIndex = 0
- 'copy each entry from the old ScriptMaps to newScriptMaps
- 'unless it is for dllPath
- for each line in ScriptMaps
- lineArray = split(line,",")
- if (lineArray(1) <> dllPath) then
- redim preserve newScriptMaps(lineIndex)
- newScriptMaps(lineIndex) = line
- lineIndex = lineIndex + 1
- else
- existsFlag = "exists"
- end if
- next
- 'If we found dllPath, then use the newScriptMaps instead
- if (existsFlag = "exists") then
- siteObj.ScriptMaps = newScriptMaps
- siteObj.SetInfo
- end if
-
-End Sub
-
-
-'*** Begin Main Code ***
-Dim WebObj
-Dim InstallDir
-Dim ShibISAPIPath
-Dim site, siteObj, sitePath
-
-' First of all look for the FileExtension
-Set WshShell = CreateObject("WScript.Shell")
-On Error Resume Next
-regValue = WshShell.RegRead("HKLM\SOFTWARE\Shibboleth\FileExtension")
-if (Err = 0) then
- ' Registry key is still there - this is an upgrade, so exit
-
-else
- ' Key is gone - a pure uninstall
-
- 'Don't show errors, we'll handle anything important
- On Error Resume Next
-
- 'Attempt to get W3SVC. If failure, end script (e.g. IIS isn't available)
- Set WebObj = GetObject("IIS://LocalHost/W3SVC")
- if (Err = 0) then
-
- 'Get the INSTALLDIR value via CustomActionData
- InstallDir = Session.Property("CustomActionData")
-
- 'Remove all trailing backslashes to normalize
- do while (mid(InstallDir,Len(InstallDir),1) = "\")
- InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
- loop
- ShibISAPIPath = InstallDir & "\lib\shibboleth\isapi_shib.dll"
-
- 'Delete ISAPI Filter
- 'First do the master service
- DeleteISAPIFilters "IIS://LocalHost/W3SVC",ShibISAPIPath
- 'Now do the websites
- for each site in WebObj
- if (site.Class = "IIsWebServer") then
- sitePath = "IIS://LocalHost/W3SVC/" & site.Name
- DeleteISAPIFilters sitePath,ShibISAPIPath
- end if
- next
-
- 'Delete File Extensions
- 'First do the master service
- DeleteFileExtensions WebObj,ShibISAPIPath
- 'Now do the websites
- for each site in WebObj
- if (site.Class = "IIsWebServer") then
- set siteObj = GetObject("IIS://LocalHost/W3SVC/" & site.Name & "/ROOT")
- DeleteFileExtensions siteObj,ShibISAPIPath
- end if
- next
-
- 'Delete Web Services Extension (universal, no need to do for each site)
- WebObj.DeleteExtensionFileRecord ShibISAPIPath
- ' Got the IIS Object
- End If
-' Sense whether this is an upgrade
-end if
\ No newline at end of file
+++ /dev/null
-'In order to get the list of versions to uninstall during deferred mode,
-'We need to set UninstallOldShibVersions property during the Immediate
-'Execution sequence. We can then read the value via CustomActionData.
-'To accomplish this, create a CA as follows:
-' Action: SetShibVersionsImmediate
-' Source: UninstallOldShibVersions
-' Type: 51
-' Target: [OLDSHIBVERSIONSFOUND]
-'Sequence this action near the beginning of InstallExecuteSequence with
-' Condition: (NOT Installed) AND (OLDSHIBVERSIONSFOUND <> "") AND (OLDSHIBPERFORMUNINSTALL = "TRUE")
-
-
-'*********************************
-'* This code is the entire body of shib_uninstall_isapi_filter.vbs
-'* The only exception is that the main function of that code is made
-'* a Sub in this code so we can call it, and we pass it the InstallDir
-'* from the Uninst.isu string instead of pulling it from the MSI.
-'*********************************
-
-Sub DeleteISAPIFilters(IISPath,dllPath)
-
- Dim filter, FiltersObj, LoadOrder, FilterArray, FilterItem
-
- Set FiltersObj = GetObject(IISPath & "/Filters")
- LoadOrder = FiltersObj.FilterLoadOrder
-
- for each filter in FiltersObj
- if (filter.Class = "IIsFilter") then
- if (filter.FilterPath = dllPath) then
-
- 'Delete the found filter here
- 'If there's anything to potentially delete...
- if (LoadOrder <> "") then
- FilterArray = split(LoadOrder,",")
- LoadOrder = ""
- for each FilterItem in FilterArray
- if (FilterItem <> filter.Name) then
- LoadOrder = LoadOrder & FilterItem & ","
- end if
- next
- 'Remove trailing comma if any filters were kept
- if (LoadOrder <> "") then
- LoadOrder = mid(LoadOrder,1,len(LoadOrder)-1)
- end if
-
- 'Set the Load Order to the new shibboleth-less order
- if (FiltersObj.FilterLoadOrder <> LoadOrder) then
- FiltersObj.FilterLoadOrder = LoadOrder
- FiltersObj.SetInfo
- end if
- end if
-
- 'Delete the actual IISFilter object
- FiltersObj.Delete "IIsFilter",filter.Name
-
- end if
- end if
- next
-
-End Sub
-
-
-Sub DeleteFileExtensions(siteObj, dllPath)
-
-Dim ScriptMaps, newScriptMaps
-Dim line, lineArray, lineIndex
-Dim fileExtension
-Dim existsFlag
-
- ScriptMaps = siteObj.ScriptMaps
- redim newScriptMaps(0)
- lineIndex = 0
- 'copy each entry from the old ScriptMaps to newScriptMaps
- 'unless it is for dllPath
- for each line in ScriptMaps
- lineArray = split(line,",")
- if (lineArray(1) <> dllPath) then
- redim preserve newScriptMaps(lineIndex)
- newScriptMaps(lineIndex) = line
- lineIndex = lineIndex + 1
- else
- existsFlag = "exists"
- end if
- next
- 'If we found dllPath, then use the newScriptMaps instead
- if (existsFlag = "exists") then
- siteObj.ScriptMaps = newScriptMaps
- siteObj.SetInfo
- end if
-
-End Sub
-
-
-Sub CleanUpISAPI(InstallDir)
-
-Dim WebObj
-'Dim InstallDir
-Dim ShibISAPIPath
-Dim site, siteObj, sitePath
-
-
-'Don't show errors, we'll handle anything important
-On Error Resume Next
-
-'Attempt to get W3SVC. If failure, end script (e.g. IIS isn't available)
-Set WebObj = GetObject("IIS://LocalHost/W3SVC")
-if (Err = 0) then
-
- 'Get the INSTALLDIR value via CustomActionData
- 'Commented out for embedding in this .vbs, passed instead
-' InstallDir = Session.Property("CustomActionData")
-
- 'Remove all trailing backslashes to normalize
- do while (mid(InstallDir,Len(InstallDir),1) = "\")
- InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
- loop
- 'Set dll Path
- ShibISAPIPath = InstallDir & "\libexec\isapi_shib.dll"
-
- 'Delete ISAPI Filter
- 'First do the master service
- DeleteISAPIFilters "IIS://LocalHost/W3SVC",ShibISAPIPath
- 'Now do the websites
- for each site in WebObj
- if (site.Class = "IIsWebServer") then
- sitePath = "IIS://LocalHost/W3SVC/" & site.Name
- DeleteISAPIFilters sitePath,ShibISAPIPath
- end if
- next
-
- 'Delete File Extensions
- 'First do the master service
- DeleteFileExtensions WebObj,ShibISAPIPath
- 'Now do the websites
- for each site in WebObj
- if (site.Class = "IIsWebServer") then
- set siteObj = GetObject("IIS://LocalHost/W3SVC/" & site.Name & "/ROOT")
- DeleteFileExtensions siteObj,ShibISAPIPath
- end if
- next
-
-
- 'Delete Web Services Extension (universal, no need to do for each site)
- WebObj.DeleteExtensionFileRecord ShibISAPIPath
-
-'Last end if
-end if
-
-End Sub
-
-
-'******** Begin Main Code ***************
-
-Dim WshShell, WshEnv, versionArray, versionElement, versionNumbers, regValue, UninstallArray, uninstallStr, UninstIsuArray, path, pathArray, NewPathEnv
-
-on error resume next
-Set WshShell = CreateObject("WScript.Shell")
-
-versionNumbers = Session.Property("CustomActionData")
-
-versionArray = split( versionNumbers, vbCRLF )
-
-for each versionElement in versionArray
- if (versionElement<>"") then
-
- 'if RegRead fails, it won't set regValue, and it will hold the last value instead. Make sure the 'last' value is ""
- regValue = ""
- on error resume next
- regValue=WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & versionElement & "\UninstallString")
- if (regValue<>"") then
- UninstallArray = split( regValue, " -f")
- 'Save off the INSTALLDIR path for later use
- UninstIsuArray = split(UninstallArray(1),"Uninst.isu")
- InstallDir = UninstIsuArray(0)
-
- 'Now create the silent uninstall string and execute it
- uninstallStr=UninstallArray(0) & " -y -a -f" & UninstallArray(1)
- WshShell.Run( uninstallStr )
-
- 'Remove entry from path environment variable
- Set WshEnv = WshShell.Environment("SYSTEM")
- PathEnv = WshEnv("PATH")
- NewPathEnv = ""
- PathArray = split(PathEnv,";")
- for each path in PathArray
- if ((path<>InstallDir & "lib\") AND (path<>InstallDir & "lib")) then
- NewPathEnv = NewPathEnv & path & ";"
- end if
- next
- NewPathEnv = mid(NewPathEnv,1,len(NewPathEnv)-1)
- WshEnv("PATH") = NewPathEnv
-
- 'Clean up all the ISAPI filters and file extension
- CleanUpISAPI InstallDir
-
- end if
-
- end if
-next
\ No newline at end of file
+++ /dev/null
-Dim WshShell, versionArray, versionElement, versionNumbers, regValue, foundVersionsStr
-Set WshShell = CreateObject("WScript.Shell")
-
-versionNumbers = Session.Property("OLDSHIBVERSIONSTOUNINSTALL")
-
-versionArray = split( versionNumbers, ";" )
-
-foundVersionsStr = ""
-
-for each versionElement in versionArray
- if (versionElement<>"") then
-
- 'if RegRead fails, it won't set regValue, and it will hold the last value instead. Make sure the 'last' value is ""
- regValue = ""
- on error resume next
- regValue=WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Shibboleth " & versionElement & "\UninstallString")
- if (regValue<>"") then
- foundVersionsStr = foundVersionsStr & "Shibboleth " & versionElement & vbCRLF
- end if
-
- end if
-next
-
-if (foundVersionsStr<>"") then
- Session.Property("OLDSHIBVERSIONSFOUND") = foundVersionsStr
-end if
\ No newline at end of file