Export (0) Print
Expand All

Managing Local and Global Link Translation Mappings

Web pages returned from a Web server published by a Web publishing rule defined in Microsoft® Internet Security and Acceleration (ISA) Server may include links containing the internal names of computers or Web sites and internal paths to Web content. Because external clients cannot resolve these names, these links will be broken unless the internal names are replaced by the public names of published Web sites. ISA Server 2006 includes a built-in Web filter named Link Translation Filter, which uses mappings to translate internal names in links on Web pages to publicly resolvable names. Each mapping translates an internal URL (or part of a URL) to a public equivalent. For example, a mapping can translate the internal URL http://team to the public URL https://www.team.contoso.com. A set of link translation mappings is called a link translation dictionary.

When link translation is enabled for a Web publishing rule, a default link translation dictionary is automatically created for each public name defined in the rule that does not contain a wildcard character (*).

When link translation is enabled for a Web publishing rule, links in content sent from the published Web site to a client are translated according to the following mappings, which are stored in the effective link translation dictionary for the rule:

  • Implicit mappings of the rule. These mappings are added automatically and map the internal name (or IP address) of the server published by the Web publishing rule to the public name (or IP address) of the Web site, or if there are multiple public names, to one of its public names.
  • Local mappings. These mappings are created by the user for the rule and map a URL containing an internal host name (or IP address) to a URL containing a publicly resolvable host name (or IP address). The URL to be translated must contain at least four characters and may contain the protocol name HTTP or HTTPS formatted as http:// or https:// and a path. A local mapping can override an implicit mapping of the rule. Local mappings are not added automatically to the effective link translation dictionaries of other rules.
  • Implicit mappings of other rules. These mappings are automatically added to the effective link translation dictionary of every Web publishing rule that is defined and enabled and has link translation enabled in the array. These mappings are derived from the implicit mappings defined in each Web publishing rule in the array. In ISA Server Enterprise Edition, implicit mappings of rules in other arrays can also be added to the effective link translation dictionary.
  • Global mappings. These mappings are created by the user for an array and apply to all Web publishing rules for which link translation is enabled in the array. Global mappings override conflicting implicit mappings of other rules. In ISA Server Enterprise Edition, they can also be applied to Web publishing rules in other arrays. The URLs specified in global mappings must begin with the protocol name HTTP or HTTPS formatted as http:// or https://.

Although local and global mappings can be managed in ISA Server Management, if you need to configure a large number of mappings, you may find it more convenient to use scripts to create and maintain these mappings from text files.

Note:
Dictionaries with a large number of mappings that are applied to Web content containing many links could detrimentally impact ISA Server performance.

The local mappings defined for a Web publishing rule are stored in the vendor parameters set represented by the FPCVendorParametersSet ISA Server administration COM object with the globally unique identifier (GUID) {3563FFF5-DF93-40eb-ABC3-D24B5F14D8AA} in the collection of vendor parameters sets of the Web publishing rule. This collection is accessed through the VendorParametersSets property of the FPCPolicyRule object representing the Web publishing rule. A single local mapping is defined by the name and value of a parameter in this vendor parameters set. The name of each parameter in this vendor parameters set specifies the internal URL in the mapping, and its value specifies the translated URL.

The vendor parameters set that contains the local mappings for a Web publishing rule is automatically created when you define the first local mapping for the Web publishing rule in ISA Server Management.

A single global mapping is defined by an FPCExplicitLinkTranslationMapping ISA Server administration COM object, and all the global mappings defined in an ISA Server array are contained in the FPCExplicitLinkTranslationMappings collection for the array. The FPCExplicitLinkTranslationMappings collection is accessed through the ExplicitLinkTranslationMappings property of the FPCWebProxy object for the array.

The FPCExplicitLinkTranslationMapping object provides the following properties for defining a global mapping:

  • OriginalUrl. This property gets or sets the internal URL (or part of a URL) in the mapping.
  • TranslatedUrl. This property gets or sets the translated URL (or part of a URL) in the mapping.

The Microsoft Visual Basic® Scripting Edition (VBScript) code in ListLocalMappings.vbs (listed later in this document) retrieves the vendor parameters set that contains local link translation mappings in the collection of vendor parameters sets accessed through the object representing the Web publishing rule specified by the user. It then displays the parameter name, which specifies the internal URL, and the corresponding value, which specifies the translated URL, for each local mapping defined in this vendor parameters set. This script, as presented, must be run on an ISA Server 2006 computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

To use this script, paste the code in the script listing into a text editor, save it in a file named ListLocalMappings.vbs, and run it from a command prompt.

Usage:

CScript ListLocalMappings.vbs RuleName

RuleName specifies the Web publishing rule whose local mappings are to be listed.

After you run the script without generating an error, you can use the redirection operator (>) to save the script output to a file. You can then edit the output file in a text editor and use it to update the local mappings defined for the Web publishing rule used to create it or for a different Web publishing rule.

Example:

CScript ListLocalMappings.vbs "My Rule" > MyLocalMappings.txt

To list the local mappings defined for a Web publishing rule
  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other ISA Server administration COM objects.

  2. Declare an FPCArray object, an FPCPolicyRules collection, an FPCPolicyRule object, and an FPCVendorParametersSet object.

  3. Get references to the FPCArray object and the FPCPolicyRules collection.

  4. Get a reference to the FPCPolicyRule object that represents the rule specified by the user.

  5. Verify that the FPCPolicyRule object retrieved represents a Web publishing rule.

  6. Get a reference to the FPCVendorParametersSet object with the GUID {3563FFF5-DF93-40eb-ABC3-D24B5F14D8AA}, which represents the vendor parameters set containing local mappings, for the FPCPolicyRule object that represents the Web publishing rule specified by the user.

  7. If the vendor parameters set exists and contains at least one local mapping, iterate through the parameter names defined in the AllNames property of the vendor parameters set and display the parameter name, which specifies the internal URL, and the corresponding value, which specifies the translated URL, for each local mapping in the vendor parameters set.

Script listing: ListLocalMappings.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script displays the local link translation mappings for a 
' user-specified Web publishing rule.
' This script can be run from a command prompt by entering the 
' following command:
'     CScript ListLocalMappings.vbs RuleName
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

'Define the constants needed
Const Error_FileNotFound = &H80070002
Const fpcPolicyRuleWebPublishing = &H02
Const MappingsVpsGUID = "{3563FFF5-DF93-40eb-ABC3-D24B5F14D8AA}"

Main(WScript.Arguments)

Sub Main(args)
    If(args.Count <> 1) Then
        Usage()
    End If
    ListLocalMappings args(0)
End Sub

Sub ListLocalMappings(ruleName)

    ' Create the root object.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject("FPC.Root")

    'Declare the other objects needed.
    Dim isaArray   ' An FPCArray object
    Dim rules      ' An FPCPolicyRules collection
    Dim rule       ' An FPCPolicyRule object
    Dim vpSet      ' An FPCVendorParametersSet object
    Dim allNames   ' A Variant
    Dim name       ' A String
    Dim i          ' An Integer

    ' Get references to the array object and
    ' the policy rules collection.
    Set isaArray = root.GetContainingArray()
    Set rules = isaArray.ArrayPolicy.PolicyRules

    On Error Resume Next
    Set rule = rules.Item(ruleName)
    If Err.Number = Error_FileNotFound Then
        WScript.Echo _
            "The Web publishing rule specified could not be found."
        WScript.Quit
    End If
    On Error GoTo 0
    If rule.Type <> fpcPolicyRuleWebPublishing Then
        WScript.Echo "The rule specified is not a Web publishing rule."
        WScript.Quit
    End If

    ' Get a reference to the vendor parameters set containing the 
    ' local link translation mappings defined for the rule.
    On Error Resume Next
    Set vpSet = rule.VendorParametersSets.Item(MappingsVpsGUID)
    If Err.Number = Error_FileNotFound Then
        WScript.Echo _
            "There are no local mappings defined for this rule."
    Else

        ' Display the local mappings defined for the rule.
        WScript.Echo "The local mappings " & vbCrLf _ 
            & "defined for the rule " & ruleName & " are:"
        allNames = vpSet.AllNames
        i = 1
        For Each name In allNames
            WScript.Echo "   " & i & ". Replace " & name & " by " _
                & vpSet.Value(name)
            i = i + 1
        Next
        If i = 1 Then
            WScript.Echo _
                "   There are no local mappings for this rule."
        End If
    End If
    On Error GoTo 0
End Sub 

Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  CScript " & WScript.ScriptName & " RuleName" & VbCrLf _
        & "" & VbCrLf _
        & "  RuleName - Name of a Web publishing rule" 
    WScript.Quit
End Sub

The Microsoft Visual Basic Scripting Edition (VBScript) code in AddLocalMappingsFromFile.vbs (listed later in this document) retrieves the vendor parameters set that contains local link translation mappings in the collection of vendor parameters sets accessed through the object representing the Web publishing rule specified by the user. It then removes all the local mappings defined in this vendor parameters set, and adds the local mappings from the user-specified file to the Web publishing rule. This script, as presented, must be run on an ISA Server 2006 computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

The text file must contain a list of mappings consisting of two strings separated by a tab character with the strings for each mapping on a separate line. The first string on each line specifies the internal URL of the mapping, and the second string specifies the translated URL of the mapping. If the file contains more than one mapping for the same internal URL, each successive mapping with the same internal URL will overwrite the previous one.

Important:
The URL to be translated must contain at least four characters and may contain the protocol name HTTP or HTTPS formatted as http:// or https:// and a path.

To use this script, paste the code in the script listing into a text editor, save it in a file named AddLocalMappingsFromFile.vbs, and run it from a command prompt.

Usage:

CScript AddLocalMappingsFromFile.vbs FileName RuleName

FileName specifies the text file from which the local mappings are to be added.

RuleName specifies the Web publishing rule to which the local mappings are to be added.

To add local mappings to a Web publishing rule from a file
  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other ISA Server administration COM objects.

  2. Declare an FPCArray object, an FPCPolicyRules collection, an FPCPolicyRule object, an FPCVendorParametersSet object, a FileSystemObject object, and a TextStream object.

  3. Get references to the FPCArray object and the FPCPolicyRules collection.

  4. Get a reference to the FPCPolicyRule object that represents the rule specified by the user.

  5. Verify that the FPCPolicyRule object retrieved represents a Web publishing rule.

  6. Try to get a reference to the FPCVendorParametersSet object with the GUID {3563FFF5-DF93-40eb-ABC3-D24B5F14D8AA}, which represents the vendor parameters set containing local mappings, for the FPCPolicyRule object that represents the Web publishing rule specified by the user. If this vendor parameters set does not exist, call the Add method on the collection of vendor parameters sets accessed through the VendorParametersSets property of the FPCPolicyRule object representing the Web publishing rule to create it.

  7. Create an instance of the FileSystemObject object, and call the OpenTextFile method on it to retrieve a TextStream object that represents the text file specified by the user.

  8. In a For…Next loop, call the RemoveValue method on the object representing the vendor parameters set containing local mappings for each parameter name defined in the AllNames property to clear the existing local mappings defined for the rule.

  9. In a While loop, call the ReadLine method of the TextStream object to read each successive line in the text file, separate the text read in each line into two strings at the tab character, and use the Value property of the vendor parameters set to set the first string (the internal URL) as the name of a new parameter and to set the second string (the translated URL) as the value associated with it.

  10. Call the Save method of the object representing the Web publishing rule to write the changes in the stored configuration.

Script listing: AddLocalMappingsFromFile.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script adds local link translation mappings from a user- 
' specified file to a user-specified Web publishing rule. If the file 
' contains more than one mapping for the same internal URL, each 
' successive mapping with the same internal URL will overwrite the
' previous one.
' Note that the text file must contain a list of mappings consisting of 
' two strings separated by a tab character with each mapping on a
' separate line.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

'Define the constants needed
Const MappingsVpsGUID = "{3563FFF5-DF93-40eb-ABC3-D24B5F14D8AA}"
Const Error_FileNotFound = &H80070002
Const fpcPolicyRuleWebPublishing = &H02
Const ForReading = 1

Main(WScript.Arguments)

Sub Main(args)
    If(args.Count <> 2) Then
        Usage()
    End If
    AddLocalMappings args(0), args(1)
End Sub

Sub AddLocalMappings(fileName, ruleName)

    ' Create the root object.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject("FPC.Root")

    'Declare the other objects needed.
    Dim isaArray    ' An FPCArray object
    Dim rules       ' An FPCPolicyRules collection
    Dim rule        ' An FPCPolicyRule object
    Dim vpSet       ' An FPCVendorParametersSet object
    Dim fso         ' A FileSystemObject object
    Dim fileStream  ' A TextStream object
    Dim textRead    ' A String
    Dim name        ' A String
    Dim value       ' A String
    Dim pos         ' An Integer
    Dim allNames    ' A Variant

    ' Get references to the array object and
    ' the policy rules collection.
    Set isaArray = root.GetContainingArray()
    Set rules = isaArray.ArrayPolicy.PolicyRules

    On Error Resume Next
    Set rule = rules.Item(ruleName)
    If Err.Number = Error_FileNotFound Then
        WScript.Echo _
            "The Web publishing rule specified could not be found."
        WScript.Quit
    End If
    On Error GoTo 0
    If rule.Type <> fpcPolicyRuleWebPublishing Then
        WScript.Echo "The rule specified is not a Web publishing rule."
        WScript.Quit
    End If

    ' Get a reference to the vendor parameters set containing the 
    ' local link translation mappings for the rule. 
    ' If this vendor parameters set does not exist,create it.
    On Error Resume Next
    Set vpSet = rule.VendorParametersSets.Item(MappingsVpsGUID)
    If Err.Number = Error_FileNotFound Then
        WScript.Echo _
            "Creating the vendor parameters set for local mappings..."
  Err.Clear
        Set vpSet = rule.VendorParametersSets.Add(MappingsVpsGUID)
    End If
    On Error GoTo 0

    Set fso = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
    Set fileStream = fso.OpenTextFile(fileName, ForReading)
    If Err.Number <> 0 Then
        WScript.Echo "The file specified could not be found."
        WScript.Quit
    End If
    On Error GoTo 0

    ' Clear the existing local mappings for the rule and then add
    ' the local mappings from the file.
    WScript.Echo "Removing the existing local mappings for the rule " _ 
       & ruleName & "..."
    allNames = vpSet.AllNames
    For Each name In allNames
        vpSet.RemoveValue name
    Next
    WScript.Echo "Adding local mappings from the file "  _ 
        & fileName & "..."
    Do While fileStream.AtEndOfStream <> True
        textRead = fileStream.ReadLine
        If textRead <> "" Then
            pos = InStr(1, textRead, vbTab, vbTextCompare)
            If (pos <> 0) Then
                name = Left(textRead, pos - 1)
                value = Right(textRead, Len(textRead) - pos)
                vpSet.Value(name) = value
            End If
        End If
    Loop
    rule.Save
    WScript.Echo "Done!"
End Sub 

Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  CScript " & WScript.ScriptName & " FileName RuleName" _
        & VbCrLf _
        & "" & VbCrLf _
        & "  FileName - Text file containing a list of mappings" _
        & VbCrLf _
        & "  RuleName - Name of a Web publishing rule" 
    WScript.Quit
End Sub

The Microsoft Visual Basic Scripting Edition (VBScript) code in ListGlobalMappings.vbs (listed later in this document) retrieves the collection of global mappings defined in the local array and displays the internal URL and translated URL of each mapping. This script, as presented, must be run on an ISA Server 2006 computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

To use this script, paste the code in the script listing into a text editor, save it in a file named ListGlobalMappings.vbs, and run it from a command prompt.

Usage:

CScript ListGlobalMappings.vbs

After you run the script without generating an error, you can use the redirection operator (>) to save the script output to a file. You can then edit the output file in a text editor and use it to update the global mappings defined for the local array.

Example:

CScript ListGlobalMappings.vbs > MyGlobalMappings.txt

To list the global mappings defined in the local array
  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other ISA Server administration COM objects.

  2. Declare an FPCArray object, an FPCExplicitLinkTranslationMappings collection, and an FPCExplicitLinkTranslationMapping object.

  3. Get references to the FPCArray object and the FPCExplicitLinkTranslationMappings collection.

  4. If at least one global mapping is defined in the collection, iterate through the collection and display the internal URL retrieved from the OriginalUrl property and the translated URL retrieved from the TranslatedUrl property for each global mapping defined in the collection.

Script listing: ListGlobalMappings.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script retrieves the collection of global link translation 
' mappings defined in the local array and displays the internal URL 
' and translated URL of each mapping.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

Sub ListExplicitMappings()

    ' Create the root object.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject("FPC.Root")

    ' Declare the other objects needed.
    Dim isaArray  ' An FPCArray object
    Dim mappings  ' An FPCExplicitLinkTranslationMappings collection
    Dim mapping   ' An FPCExplicitLinkTranslationMapping object

    ' Get references to the array object and
    ' the collection of global mappings.
    Set isaArray = root.GetContainingArray()
    Set mappings = _
        isaArray.ArrayPolicy.WebProxy.ExplicitLinkTranslationMappings

    'Display each global mapping.
    If mappings.Count > 0 Then
        For Each mapping In mappings
            WScript.Echo "Replace " & mapping.OriginalUrl & " by " _
                         & mapping.TranslatedUrl
        Next
    Else
        WScript.Echo _
            "No global mappings are defined in the local array."
    End If
End Sub 

ListExplicitMappings

The Microsoft Visual Basic Scripting Edition (VBScript) code in AddGlobalMappingsFromFile.vbs (listed later in this document) retrieves the collection of global link translation mappings defined for the local array, removes all the global mappings defined in this collection, and then adds the global mappings from a user-specified file to the collection. This script, as presented, must be run on an ISA Server 2006 computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

The text file must contain a list of mappings consisting of two strings separated by a tab character with the strings for each mapping on a separate line. The first string on each line specifies the internal URL of the mapping, and the second string specifies the translated URL of the mapping. If the file contains more than one mapping for the same internal URL, only the first mapping for the internal URL is added.

Important:
The URLs specified in global mappings must begin with the protocol name HTTP or HTTPS formatted as http:// or https://.

To use this script, paste the code in the script listing into a text editor, save it in a file named AddGlobalMappingsFromFile.vbs, and run it from a command prompt.

Usage:

CScript AddGlobalMappingsFromFile.vbs FileName

FileName specifies the text file from which the global mappings are to be added.

To add global mappings for the local array from a file
  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other ISA Server administration COM objects.

  2. Declare an FPCArray object, an FPCExplicitLinkTranslationMappings collection, a FileSystemObject object, and a TextStream object.

  3. Get references to the FPCArray object and the FPCExplicitLinkTranslationMappings collection.

  4. Create an instance of the FileSystemObject object, and call the OpenTextFile method on it to retrieve a TextStream object that represents the text file specified by the user.

  5. In a While loop, call the Remove method on the FPCExplicitLinkTranslationMappings collection for each mapping defined in the collection to clear the existing global mappings defined for the array.

  6. In a While loop, call the ReadLine method of the TextStream object to read each successive line in the text file, separate the text read in each line into two strings at the tab character, and call the Add method of the FPCExplicitLinkTranslationMappings collection with the first string (the internal URL) as the OriginalUrl parameter of the method and the second string (the translated URL) as the TranslatedUrl parameter.

  7. Call the Save method of the object representing the local array with the first parameter set to True to write the changes in the stored configuration.

Script listing: AddGlobalMappingsFromFile.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script adds global link translation mappings for the local array 
' from a user-specified file. 
' Note that the text file must contain a list of mappings consisting of 
' two strings separated by a tab character with each mapping on a
' separate line.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

' Define the constants needed.
Const Error_FileNotFound = &H80070002
Const Error_FileAlreadyExists = &H800700B7
Const Error_NoProtocol = &HC00403E0
Const ForReading = 1

Main(WScript.Arguments)

Sub Main(args)
    If(args.Count <> 1) Then
        Usage()
    End If
    AddGlobalMappings args(0)
End Sub

Sub AddGlobalMappings(fileName)

    ' Create the root object.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject("FPC.Root")

    ' Declare the other objects needed.
    Dim isaArray    ' An FPCArray object
    Dim mappings    ' An FPCExplicitLinkTranslationMappings collection
    Dim fso         ' A FileSystem object
    Dim fileStream  ' A TextStream object
    Dim textRead    ' A String
    Dim original    ' A String
    Dim translated  ' A String
    Dim i           ' An Integer
    Dim pos         ' An Integer

    ' Get references to the array object and
    ' the collection of global mappings.
    Set isaArray = root.GetContainingArray()
    Set mappings = _
        isaArray.ArrayPolicy.WebProxy.ExplicitLinkTranslationMappings

    Set fso = CreateObject("Scripting.FileSystemObject")
    On Error Resume Next
    Set fileStream = fso.OpenTextFile(fileName, ForReading)
    If Err.Number <> 0 Then
        WScript.Echo "The file specified could not be found."
        WScript.Quit
    End If
    On Error GoTo 0

    ' Clear the existing global mappings for the array and then
    ' add the global mappings from the file.
    WScript.Echo _
        "Removing the existing user-defined global mappings..." 
    i = mappings.Count
    Do While i > 0
        mappings.Remove i
        i = i - 1
    Loop
    WScript.Echo "Adding global mappings from the file "  _ 
        & fileName & "..."
    Do While fileStream.AtEndOfStream <> True
        textRead = fileStream.ReadLine
        If textRead <> "" Then
            pos = InStr(1, textRead, vbTab, vbTextCompare)
            If (pos <> 0) Then
                original = Left(textRead, pos - 1)
                translated = Right(textRead, Len(textRead) - pos)
                On Error Resume Next
                mappings.Add original, translated
                If Err.Number = Error_FileAlreadyExists Then
                    WScript.Echo "A duplicate mapping for " _
                        & original & " was ignored."
                    Err.Clear
                ElseIf Err.Number = Error_NoProtocol Then
                    WScript.Echo "A mapping without a valid " _
                        & "protocol was ignored."
                    Err.Clear
                End If
                On Error GoTo 0
            End If
        End If
    Loop
    isaArray.Save True
    WScript.Echo "Done!"
End Sub 

Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  CScript " & WScript.ScriptName & " FileName" & VbCrLf _
        & "" & VbCrLf _
        & "  FileName  - Text file containing a list of mappings" 
    WScript.Quit
End Sub
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft