Creating a VPN connection using DotRas - making sure credentials are remembered

3.8k Views Asked by At

I am using DotRas to create a VPN connection. This is working fairly well (preshared key, credentials and such).

The only thing I am having a real difficulty with is making sure the credentials actually persist. See the following image. I cannot seem to find a way to make sure that checkbox is actually checked. I have tried everything I could remember.

Having this unchecked renders the saved credentials virtually nonexistent as I am asked to enter username/password upon connection. Yet if I go back to edit this info, the credentials are still there!

If I click on the checkbox manually and do a Save, everything works as expected. Any ideas? How can I make sure Remember my sign-in info is checked (programmatically)?

This is how it appears on my Windows 10

2

There are 2 best solutions below

0
On

Try with

VpnEntry.Options.CacheCredentials = true;

On my Windows 10 professional works.

0
On

I found that if I update the credentials, E.g:

VpnEntry.UpdateCredentials(new System.Net.NetworkCredential(Environment.UserName, string.Empty, Environment.UserDomainName));

then, at least on Windown 7, the connection will appear with "Save this username and password..." option checked. Unfortunatelly I can't get it working on Windows 10.

I would look into pinvoking the API's yourself. At least that's what I'm going to do. Will post back with progress.

Rasapi32.dll :: RasSetCredentials - https://msdn.microsoft.com/en-us/library/aa377811(VS.85).aspx