![Fortinet FortiGate Voice 4.0 MR1 Administration Manual Download Page 59](http://html1.mh-extra.com/html/fortinet/fortigate-voice-4-0-mr1/fortigate-voice-4-0-mr1_administration-manual_2322091059.webp)
Using the FortiClient API
Setting and monitoring a security policy
FortiClient Endpoint Security Version 4.0 MR1 Administration Guide
04-40001-99556-20090626
53
http://docs.fortinet.com/
•
Feedback
Monitoring the connection
There are both function-based and event-based ways to monitor the VPN connection.
Events
The FortiClient API includes event calls for which you write appropriate code. Using
events, you can provide live status information for users. This example shows how an
application could respond to the OnConnect and OnDisconnect events by updating a user
interface display. A check box, ConnectCheck, is selected when the VPN connects and
cleared when the VPN disconnects.
Private Sub VPN1_OnConnect(ByVal bstrTunnelName As String)
ConnectCheck.Value = 1
textName = bstrTunnelName
End Sub
Private Sub VPN1_OnDisconnect(ByVal bstrTunnelName As String)
ConnectCheck.Value = 0
textName = bstrTunnelName
End Sub
There is also an OnIdle event.
Functions
At any time, you can programmatically determine which VPN connection is active using
the GetActiveTunnel function, like this:
TunnelName = VPN1.GetActiveTunnel
The returned string is empty if no VPN tunnel is up.
The boolean function IsConnected returns True if the named connection is up, like this:
If IsConnected("Office") Then
Rem perform functions requiring Office VPN
....
End If
There is also an IsIdle function.
Setting and monitoring a security policy
The FortiClient application can enforce a security policy. Users cannot use a VPN
connection unless the FortiClient settings comply with the policy. The security policy can
require that any or all of the following features are enabled:
• Antivirus (real-time protection)
• Antispam
• Firewall (Normal mode)
• Web Filter
This is usually applied in an enterprise environment to provide security when users
connect to the corporate network through a VPN. A FortiManager unit can deploy the
security policy to FortiClient computer.
The FortiClient API can also create a security policy. This section uses example code
snippets in Visual Basic to show how to set and monitor a corporate security policy
programmatically.