This project is read-only.

VPN Connection Using DotRas

Sep 27, 2012 at 9:24 PM
Edited Sep 27, 2012 at 9:26 PM


I need help on creating VPN connections and send all network traffic through, using DotRas. Simply I want to know how I can connect to VPN Server with each of PPTP, L2TP/IPSec & SSTP protocols since I have the server address, the protocol name, the authentication encryption type (auto detect, CHAP, MS-CHAP, PAP, ...) and also the username and password of the account created on the RADIUS server. Certainly the VPN server itself will check the login information and the only thing we do is making these connections.

Please provide me a clear description via C# codes. I need to make three types of connections:


L2TP/IPSec => IPSec Preshared Key needed

SSTP => It's a valid SSL connection

Many Thanks

Sep 29, 2012 at 7:55 PM

Like I tell everyone that's trying to create entries manually, you're better off creating the connection in Windows and then replicating that connection via code. Aside from specific questions regarding connection options, you will not see any advice other than that on here how to create an entry. If you do not try to replicate a working connection, you will basically be guessing which properties you need to set on the entry for it to be successful. Once you know your entry will work using the standard Windows network connection dialer, that's a good starting point to begin replicating that entry.

Here's a link with some instructions that might help you replicate the connection:

The only thing I see that might be a problem is the operating systems you're targetting for your project. Since SSTP is only available in Windows 7, if you want to support Windows 2000, XP, and/or Vista you'll need to work out how you plan on building with separate assemblies. I would imagine this would be the WINXP and WIN7 build flavors you'd be interested in if you were.

Also, you'll want to look at the CreateAndDialVpnEntry example project included with the SDK for an example how to create and dial a VPN connection.

Oct 4, 2012 at 9:32 PM
Edited Oct 4, 2012 at 11:40 PM

Thank you Jeff. Just two other questions:

1. Is it possible to hide created connection entry at windows?

2. How can I assign IPSec Pre-shared Key into the connection?

Many Thanks

Oct 5, 2012 at 12:32 AM

1. Is it possible to hide created connection entry at windows?

If you're putting the connection in one of the default phonebooks, no. If you put it in a custom location, it isn't exactly hidden... but it is less discoverable.

2. How can I assign IPSec Pre-shared Key into the connection?

You just need to call the RasEntry.UpdateCredentials method and specify the PreSharedKey.Client overload of the method with the password you wish to use.