I am working with the basic Cisco VPN client (v.5 I believe). Is there anyway to determine programatically if a partciular profile (or any profile for that matter) is connected?
I'm looking to somehow get a status from the client itself. I don't want to have to try to ping some IP on the other end of the VPN to see if I get a response.
There are several ways, actually, without using the API (which I still cant find/DL)
One of the easiest ways is to check a registry setting found at: HKEY_LOCAL_MACHINE\SOFTWARE\Cisco Systems\VPN Client\AllAccess\TunnelEstablished (0 or 1)
Another way is to do it is to detect it by the name of the network interface it establishes via using ManagementObjectSearcher, sample code below:
Yet another way is to use process.start to run a CLI (command line) of "vpnclient stat", redirect standard output to a stringbuilder in your app and then check the string whether it contains appropriate data - for more info on this see here:
http://www.cisco.com/en/US/docs/security/vpn_client/cisco_vpn_client/vpn_client46/administration/guide/vcAch5.html
Below a vbs script to check the connection status:
As "diciu" wrote, you can query the System Configuration framework. The programmatic equivalent of the scutil command that he gave is something like
Using the above, you can tell if the Cisco VPN client is connected. You can then do something similar to get the DNS servers associated with the VPN connection. I compare the resulting DNS servers to the DNS server of my company to tell if I'm VPN'd into my company. Klunky, but it works and it's fast - no waiting for a ping to timeout.
Note that with the recent version of the Cisco VPN Client, Cisco published an API. Unfortunately, it's only for Microsoft Windows. Maybe they'll produce one for Macs some day.
There is an API for Cisco VPN (vpnapi.dll).
I am unaware of any APIs for Cisco VPN client but you could use the underlying OS.
On Mac OS X, you can query the System Configuration framework because when Cisco VPN client connects it creates a number of keys in the configuration directory (DNS and stuff):
The programmatic equivalent of the above can be achieved in plain C Carbon or ObjC Cocoa.
Well if all else fails, parse the output of "route". The routing used by CiscoVPN has a telltale mark there.