Need help to start: create conn on-the-fly with custom phone number and credentials

May 19, 2010 at 9:34 AM
Edited May 19, 2010 at 9:35 AM

Good morning !

First of all, thank you Jeff for this great piece of code! :-)

This is my scenario.

I'm developing a plugin-based application; a plugin can use internet to do his work (consuming a WS, for example).

I need to do this:

  • Check if there's a valid internet connection (LAN connection, ADSL, or a RAS dialup just "up and running")
  • if true, do the work "and leave all things the way they are now" (do no disconnect)  
  • if false:
    • read a config file where our customers can set their RAS dialup connection, including:
      • nome of connection
      • Using-order of connection (first to try to rise up, second, etc...)
      • credential (username and password)
      • phone number to call
    • Dial the first connection
      • if dial ok, do the work and then disconnect
      • if not dial, try to rise up second connection in order, and so on...

Before the discover of DotRAS, I do that I explained before using a RAS wrapper class found on the net; but this class can only rise up connection found in Windows, and cannot make me able to create "at runtime" a connection to use when I want, with credential I want.

Can someone point me out how can I do this?

I just need an example on creating a RAS connection on-the-fly with custom phone number and credentials (possibly with no admin annoyng stuff... :-))

Thank you in advance!

Nando

 

Coordinator
May 19, 2010 at 1:51 PM

As of the 1.1 SDK there is no way to check if a connection to the Internet exists, since simply having a network connection does not guarantee connectivity to the Internet. I still have to get the Windows API implemented that does that check.

The CreateAndDialVpnEntry example included with the SDK should give you a good starting point for the rest of what you're looking to do. If you do not want the connection to be displayed in the Network Connections window, just simply open the phonebook in a custom location before adding the entries to it.

RasPhoneBook pbk = new RasPhoneBook();
pbk.Open("C:\\Blah.pbk");

Any location will work, might be wise to store the phonebook with your application.

That "no admin annoying stuff" as you call it is dependent on which platforms you're using. Windows Vista did not do much to protect the RAS API in Windows, whereas Windows 7 added much (if not all) of the API under the UAC. Your application will need to have elevated privileges on these operating systems in order to interact with everything.

May 19, 2010 at 2:55 PM
Edited May 19, 2010 at 2:56 PM
jeff_winn wrote:

As of the 1.1 SDK there is no way to check if a connection to the Internet exists, since simply having a network connection does not guarantee connectivity to the Internet. I still have to get the Windows API implemented that does that check.

Yes, I know this problem. But in my current implementation I found a way that works at 99%; in 1% of cases there's my library don't recognize LAN connection, so there's a check in config to bypass tthe control and consider computer always online.

The CreateAndDialVpnEntry example included with the SDK should give you a good starting point for the rest of what you're looking to do. If you do not want the connection to be displayed in the Network Connections window, just simply open the phonebook in a custom location before adding the entries to it.

RasPhoneBook pbk = new RasPhoneBook();
pbk.Open("C:\\Blah.pbk");

Any location will work, might be wise to store the phonebook with your application.

So I can/must create a phonebook file to do this? Well, this could be a good solution for me!

That "no admin annoying stuff" as you call it is dependent on which platforms you're using. Windows Vista did not do much to protect the RAS API in Windows, whereas Windows 7 added much (if not all) of the API under the UAC. Your application will need to have elevated privileges on these operating systems in order to interact with everything.

Ok, security is security, after all... :-)

Thanks for your quick answer!

 

Bye, Nando

 

Coordinator
May 19, 2010 at 7:48 PM
jesus_was_rasta wrote:

So I can/must create a phonebook file to do this? Well, this could be a good solution for me!

Yeah, that's just the way Windows works. The most basic type of modem based connection does not need an entry in a phonebook, however everything else does require an entry. The RAS API just happens to store them in a file, the project just interacts with their API to allow for programmatic access. Your passwords and such could be stored in a database, or you can store them with the entry and let Windows manage the data security. However, storing the credentials with the entry means you will not be able to share passwords between users on the machine.

May 20, 2010 at 2:01 PM
jeff_winn wrote:

..., or you can store them with the entry and let Windows manage the data security.

In what way Windows secure my files? I see that *.pbk files are plain text files.
Are passwords saved in just plain text in the *.pbk file?
If so, I can easily provide a custom crypt/decrypt algoritm to store encrypted data, even if for our target customers is not critical have connection infos in plain text files.

Where can I find a more documentation about *.pbk files structure?
Have you some links about?

Thanks again for all!
Nando

Coordinator
May 20, 2010 at 5:32 PM

The files aren't encrypted, nor can they be as Windows has to be able to read the information in those files. The credentials are not stored in the files, I'm not sure where Windows stores them... might be in the protected data storage. Keep in mind, there is no requirement that you must use RAS to store the user credentials... if you feel more comfortable securing that information in a way you see fit, that is up to you.

The file structure is determined by Microsoft, with the amount of various combinations of what needs to be in there and how that maps to the API there is no documentation that I'm aware of. I don't do anything with the files, I let the RAS API take care of all that for me.