Share via


MoveUp Method of the IFPCUserAgentMappings Interface

The MoveUp method moves the specified User-Agent mapping one step up the list of User-Agent mappings, which corresponds to the order in which the User-Agent mappings are tested to find a mapping that matches the User-Agent header in a request. If the first mapping in the list does not match the User-Agent header in a request, the second mapping is tested, and so on.

C++

Syntax

HRESULT MoveUp(
  [in]  long index
);

Parameters

  • index
    Required. Index (the current position indicated by the Order property of the IFPCUserAgentMapping interface) of the User-Agent mapping to move up.

Return Value

This method returns S_OK if the call is successful; otherwise, it returns an error code.

Visual Basic

Syntax

Sub MoveUp( _
  ByVal index As Long _
)

Parameters

  • index
    Required. Index (the current position indicated by the Order property of the FPCUserAgentMapping object) of the User-Agent mapping to move up.

Return Value

This method has no return values. If the call is unsuccessful, an error is raised that can be intercepted by using an error handler.

Example Code

This VBScript script moves the specified User-Agent mapping one step up the list of User-Agent mappings.

Option Explicit
 
' Define the constant needed.
Const Error_TypeMismatch = &HD
const Error_InvalidParameter = &H80070057
 
Main(WScript.Arguments)
 
Sub Main(args)
    If(args.Count <> 1) Then
        Usage()
    Else
       MoveUpMapping args(0)
    End If
End Sub
 
Sub MoveUpMapping(mappingId)
 
    ' 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 FPCUserAgentMappings collection
    ' Get references to the array object and
    ' the User-Agent mappings collection.
    Set isaArray = root.GetContainingArray()
    Set mappings = isaArray.RuleElements.UserAgentMappings
 
    ' Move up the specified User-Agent mapping.
    On Error Resume Next
    mappings.MoveUp(CInt(mappingId))
    If Err.Number = Error_TypeMismatch Then
        WScript.Echo "The Mapping parameter specified is not a number."
        WScript.Quit
    ElseIf Err.Number = Error_InvalidParameter Then
        WScript.Echo "The mapping specified cannot be moved or does not exist."
        WScript.Quit
    Else
        WScript.Echo "Moving the User-Agent mapping specified up..."
    End If
    On Error GoTo 0
 
    ' Save the changes to the collection of User-Agent mappings.
    mappings.Save
    WScript.Echo "Done!"
End Sub
 
Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  " & WScript.ScriptName & " Mapping" & VbCrLf _
        & "" & VbCrLf _
        & "  Mapping   Number of the mapping." 
    WScript.Quit
End Sub

Remarks

Use the MoveDown method to move a User-Agent mapping one step down the list of User-Agent mappings.

Requirements

Client Requires Windows 7 or Windows Vista.
Server Requires Windows Server 2008 R2 or Windows Server 2008 x64 Edition with SP2.
Version Requires Forefront Threat Management Gateway (TMG) 2010.
IDL

Declared in Msfpccom.idl.

DLL

Requires Msfpccom.dll.

See Also

FPCUserAgentMappings

Send comments about this topic to Microsoft

Build date: 6/30/2010