Share via


IFPCUserAgentMapping::Enabled property

Applies to: desktop apps only

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

This property is read/write.

Syntax

HRESULT put_Enabled(
  VARIANT_BOOL fEnabled
);

HRESULT get_Enabled(
  VARIANT_BOOL *pfEnabled
);
' Data type: Boolean

Property Enabled( _
  ByVal fEnabled As VARIANT_BOOL, _
  ByVal pfEnabled As VARIANT_BOOL _
) As Boolean

Property value

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

Error codes

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

Remarks

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

Examples

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

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 (64-bit only)

Version

Forefront Threat Management Gateway (TMG) 2010

IDL

Msfpccom.idl

DLL

Msfpccom.dll

See also

FPCUserAgentMapping

 

 

Build date: 7/12/2010