![Fortinet FortiGate Voice 4.0 MR1 Administration Manual Download Page 58](http://html1.mh-extra.com/html/fortinet/fortigate-voice-4-0-mr1/fortigate-voice-4-0-mr1_administration-manual_2322091058.webp)
Controlling a VPN
Using the FortiClient API
FortiClient Endpoint Security Version 4.0 MR1 Administration Guide
52
04-40001-99556-20090626
http://docs.fortinet.com/
•
Feedback
This creates VPN1 as the FortiClient object.
Depending on your development environment, you might also need a type library file. You
can find the file FCCOMIntDLL.tlb in the FortiClient .zip installation package.
Retrieving a list of VPN connection names
If needed, you can obtain a list of the VPN connections configured in the FortiClient
application. The GetTunnelList function returns an array of the names.
tunnelList = VPN1.GetTunnelList
Typically, an application might put the tunnel names into a list from which the user
chooses the required tunnel name. In this example, the list control List1 is populated with
the tunnel names:
List1.Clear
For i = LBound(tunnelList) To UBound(tunnelList)
List1.AddItem (tunnelList(i))
Next
Opening the VPN tunnel
Use the Connect method to establish the tunnel. The only parameter is the tunnel name,
as configured in the FortiClient application. In this example, the tunnel name is “Office”:
VPN1.Connect “Office”
Responding to XAuth requests
If the VPN peer requires you to supply XAuth credentials, you can easily provide for this
by writing code that responds to the On XAuthRequest event. In this example, a small
window opens in which the user enters the user name and password.
Private Sub VPN1_OnXAuthRequest(ByVal bstrTunnelName As String)
Dialog.Show 1
outUserName = ""
outPassword = ""
outSavePassword = False
If Not Dialog.Cancelled Then
outUserName = Dialog.UserName
outPassword = Dialog.Password
outSavePassword = Dialog.SavePassword
End If
VPN1.SendXAuthResponse bstrTunnelName, outUserName,
outPassword, outSavePassword
End Sub