Enabled Property of the IFPCUserAgentMapping Interface

The Enabled property gets or sets a Boolean value that indicates whether the User-Agent mapping is enabled.

C++

HRESULT put_Enabled(
    VARIANT_BOOL fEnabled
);
HRESULT get_Enabled(
    VARIANT_BOOL* pfEnabled
);

Parameters

  • fEnabled
    Boolean value that indicates whether the User-Agent mapping is enabled.

  • pfEnabled
    Pointer to a Boolean variable that is set on return to VARIANT_TRUE if the User-Agent mapping is enabled, or to VARIANT_FALSE if the User-Agent mapping is disabled.

Return Value

These property methods return S_OK if the call is successful; otherwise, they return an error code.

Visual Basic

Property Enabled As Boolean

Property Value

Boolean value that indicates whether the User-Agent mapping is enabled.

Example Code

This VBScript script enables or disables the specified User-Agent mapping.

Option Explicit
 
' Define the constant needed.
const Error_FileNotFound = &H80070002
 
Main(WScript.Arguments)
 
Sub Main(args)
    If(args.Count <> 2) Then
        Usage()
    Else
       EnableOrDisable UCase(args(0)), args(1)
    End If
End Sub
 
Sub EnableOrDisable(action, 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
    Dim mapping     ' An FPCUserAgentMapping object
    ' Get references to the array object and
    ' the User-Agent mappings collection.
    Set isaArray = root.GetContainingArray()
    Set mappings = isaArray.RuleElements.UserAgentMappings
 
    ' Delete the specified User-Agent mapping.
    On Error Resume Next
    If IsNumeric(mappingId) Then
        mappingId = CInt(mappingId)
    End If
    If action = "ENABLE" Then
        Set mapping = mappings.Item(mappingId)
        If Err.Number = Error_FileNotFound Then
            WScript.Echo "The User-Agent mapping specified could not be found."
            WScript.Quit
        Else
            If mapping.Enabled = False Then
                WScript.Echo "Enabling the User-Agent mapping specified..."
                mapping.Enabled = True
            Else 
                WScript.Echo "The User-Agent mapping specified is already enabled."
                WScript.Quit
            End If
        End If
    ElseIf action = "DISABLE" Then
        Set mapping = mappings.Item(mappingId)
        If Err.Number = Error_FileNotFound Then
            WScript.Echo "The User-Agent mapping specified could not be found."
            WScript.Quit
        Else
            If mapping.Enabled = True Then
                WScript.Echo "Disabling the User-Agent mapping specified..."
                mapping.Enabled = False
            Else 
                WScript.Echo "The User-Agent mapping specified is already disabled."
                WScript.Quit
            End If
        End If
    Else
        WScript.Echo "The Action parameter specified is not valid."
        Usage()
    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 & " Action Mapping" & VbCrLf _
        & "" & VbCrLf _
        & "  Action    ENABLE   Enable the specified mapping." & VbCrLf _
        & "            DISABLE  Disable the specified mapping." & VbCrLf _
        & "  Mapping   Number of the mapping or string that" & VbCrLf _
        & "            specifies User-Agent headers." 
    WScript.Quit
End Sub

Remarks

This property is read/write. Its default value is True (VARIANT_TRUE in C++).

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

FPCUserAgentMapping

Send comments about this topic to Microsoft

Build date: 6/30/2010