The Add method creates a new FPCUserAgentMapping object in the collection and returns a reference to it.
HRESULT Add( [in] BSTR UserAgent, [in] FpcFBAFormsTypes FormsType, [out] IFPCUserAgentMapping** ppUserAgentMapping );
Required. Value from the FpcFBAFormsTypes enumerated type that specifies the type of authentication that will be associated with the User-Agent headers specified in the mapping. The possible values specify forms-based authentication using forms written in a specific format or Basic authentication.
Address of an interface pointer that on return points to the new IFPCUserAgentMapping interface created.
This method can return one of the following:
Function Add( _ ByVal UserAgent As String, _ ByVal FormsType As FpcFBAFormsTypes _ ) As FPCUserAgentMapping
Required. Value from the FpcFBAFormsTypes enumerated type that specifies the type of authentication that will be associated with the User-Agent headers specified in the mapping. The possible values specify forms-based authentication using forms written in a specific format or Basic authentication.
This method returns a reference to an FPCUserAgentMapping object if successful. Otherwise, an error is raised that can be intercepted by using an error handler.
Option Explicit ' Define the constants needed. Const Error_AlreadyExists = &H800700B7 Const fpcFbaHTML4 = 0 Const fpcFbaCHTML = 1 Const fpcFbaXHTML_MP = 2 Const fpcFbaHTTPBASIC = 3 Main(WScript.Arguments) Sub Main(args) If(args.Count <> 2) Then Usage() Else Select Case UCase(args(1)) Case "HTML4" AddUAMapping args(0), fpcFbaHTML4 Case "CHTML" AddUAMapping args(0), fpcFbaCHTML Case "XHTML" AddUAMapping args(0), fpcFbaXHTML_MP Case "BASIC" AddUAMapping args(0), fpcFbaHTTPBASIC Case Else WScript.Echo "The AuthType parameter specified is not valid." Usage() End Select End If End Sub Sub AddUAMapping(uaHeaders, authType) ' 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 newMapping ' An FPCUserAgentMapping object ' Get references to the array object and ' the User-Agent mappings collection. Set isaArray = root.GetContainingArray() Set mappings = isaArray.RuleElements.UserAgentMappings ' Create a new User-Agent mapping. On Error Resume Next Set newMapping = mappings.Add(uaHeaders, authType) If Err.Number = Error_AlreadyExists Then WScript.Echo "A mapping for the User-Agent headers specified already exists." WScript.Quit 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 & " UAHeaders AuthType" & VbCrLf _ & "" & VbCrLf _ & " UAHeaders String that specifies User-Agent headers." & VbCrLf _ & " AuthType HTML4 FBA with HTML 4.01 forms" & VbCrLf _ & " CHTML FBA with cHTML forms" & VbCrLf _ & " XHTML FBA with XHTML-MP forms" & VbCrLf _ & " Basic Basic authentication" WScript.Quit End Sub
The new User-Agent mapping created is added to the list of User-Agent mappings in the position preceding the last User-Agent mapping. Its ordinal position the list of User-Agent mappings, which is specified by the Order property, can be modified by calling the MoveUp and MoveDown methods.
Client | Requires Windows Vista or Windows XP. |
---|---|
Server | Requires Windows Server 2008. |
Version | Requires Forefront Threat Management Gateway (TMG). |
IDL |
Declared in Msfpccom.idl. |
DLL |
Requires Msfpccom.dll. |
Send comments about this topic to Microsoft
Build date: 11/30/2009
© 2008 Microsoft Corporation. All rights reserved.