cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Bookmark
|
Subscribe
|
2025
Views
0
Helpful
2
Replies

AnnyConnect API - C# - Connect without UI (Windows Service)

Ben.Levy11
Level 1
Level 1

I am trying to create a windows service / console app that will establish a VPN connection, perfom some actions, and then close the vpn connection.  This will happen many time throughtout the day.

 

There will be no user interaction so I need the connection to be established from the code (service).

 

In addtion, I would like to monotor the connection while it is open.

 

It looks like using the VpnApiLib (Interop.VpnApiLib) will do what I need, however I can not seem to find documentation on how to establish the connection without the AnyConnect UI poping up for credentials.

 

The connection requires a Group, UserName and Password that I will provide from code (securly!)

 

Can anyone point me to some documentation / examples of how this can be accomplished.  I am open to other options.  I believe I can do this by starting a process and capturing the output, but I would prefer a more robust solution.

 

Quick Edit..  

I am refering to and using the VpnApiClass.  Using CSharpComSample as a reference.

 

It woudl seem that this would be a fairly common thing to acomplish.  Surprised I am not finding a solution out there.

 

Thanks,

Ben.

2 Replies 2

The easiest I think of is to replace your credentials authentication with certificate authentication. this config to be done on your AnyConnect server.

 

Then using client certificate anyconnect will automatically authenticate

Thanks, unfortunately, it is not our server. That is not an option.