Solved

Setting up Microsoft VPN connection through code

Posted on 2007-12-06
10
395 Views
Last Modified: 2008-02-01
Hi. I just started my new job with an IT consulting firm last monday. The company is into IT support and consultancy with numerous clients. In order to provide support to clients vpn connections are set up to access the client's servers. The clients' setup sometimes change, like IP Address, and there are almost a hundred VPN connections to setup and its just too much for me to manually do it. I already stored all the clients info in an access db. My question is: Using Either vb6, vb.net or vbscript, can i set it up using code? and if so can you provide me something that i can work on? codes examples, articles or sites maybe. thank you very.
0
Comment
Question by:amcurso
  • 5
  • 5
10 Comments
 
LVL 9

Expert Comment

by:asawatzki
ID: 20420556
This is what I've done to replicate Dial-Up and VPN connections.  Create all the entries on one computer.  Then go into C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\  and copy the rasphone.pbk .  Copy that file to another computer and all the connections and settings should be there (you may have to reboot).  

You would probably want to try this on a few connections to make sure that it works for you before entering all 100.  In my opinion this is a little simpler then coming up with a programmatic way.  If the IP of a server changes you can make the change on one computer and copy the rasphone.pbk out again.  If that's not what you're looking for or if it doesn't work for you let me know.  
0
 

Author Comment

by:amcurso
ID: 20420614
thanks for the quick response. but i am actually thinking of building an application with the access backend and a frontend of VB6 or .net. and do the setting up of these VPN through it. I am doin this so that i can share the applicatioin to the rest of the team. hope this is possible.
0
 
LVL 9

Assisted Solution

by:asawatzki
asawatzki earned 500 total points
ID: 20421530
0
 

Author Comment

by:amcurso
ID: 20422400
the first link is the closest i could get to the solution. While i still would like to have a more structured way of doin it. RAS api on the other hand seems like to be an answer but i couldnt figure it out on how to use it since i have a limited working knowledge in api's. btw, the fist solution creates a dial up connection. am still trying to figure it out on how to create a vpn out of that solution.
0
 
LVL 9

Expert Comment

by:asawatzki
ID: 20422446
Do you mean you are still trying to figure out how to copy a VPN using rasphone.pbk, or that you are still trying to figure out how to use the API to create a VPN?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:amcurso
ID: 20422494
i did use the vbscript solution since it was easier for me to understand than the other solution you gave. and yes i dont know how to use rasphone.pbk or the RAS API for that matter. i hope you can have something explained a little bit simplier. sorry bout that. hope you'll understand. thank you.
0
 
LVL 9

Assisted Solution

by:asawatzki
asawatzki earned 500 total points
ID: 20425318
The rasphone is by far the simplest of the solutions, though it doesn't use the Access database.  Basically every time you create a VPN or Dial-Up connection in Windows it writes it to an the pbk file (which if you open it up in notepad basically has the format of a .INI file).  

If you manually created all the VPN connections on one machine, all you would have to do is:
1.  Copy the rasphone.pbk file from "C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\" or if you selected that the VPN connection be available only to the user who created it then it would be located in this folder  C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Network\Connections\Pbk\
2.  Then take it to the client computers and paste it into the same location (C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\ if you chose for the VPN connection to be used by all users or  C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Network\Connections\Pbk\ if you chose for this user only).  You could do this file copy manually or programmatically.  
3.  On the new computer if you go into network connections you should have all the same VPN connections that you had on the machine that you copied from.

I just think you may be overcomplicating things with this Access database and programmatic entry.  It is just so easy to copy that one file with all the different connections from one machine to another.  And if your IP changes all you have to do is make the change on one machine and then replicate out that one file again.
0
 

Author Comment

by:amcurso
ID: 20427156
Actually, i didnt think its this complicated, well i know now. Here is what the real score here. My boss gave me an excel file with our clients data which includes among other things, the Public and private, domain and so on. As i have mentioned that i am using an access db, it is because i converted the excel file into it so i could do the search and get the result in a well layed out format. All i was thinking of achieving was when i get the result for a particular client, i would like to click a button and connect to that client. And for this reason that the thought of creating an application in vb came to mind. anyway,
thank you very much. you just opened me to a new area. i really appreciated what you did. I'll keep this thread open for a couple of days more before accepting your solution. but if you have any other suggestion i would really appreciate it though the solutions above are great.
0
 
LVL 9

Accepted Solution

by:
asawatzki earned 500 total points
ID: 20430426
Ok so just to clarify, I think you would want to use the RasSetEntryProperties API instead of RasCreatePhonebookEntry if you want to programmatically create these connections look here for details:   http://msdn2.microsoft.com/en-us/library/aa377827.aspx .  The RasCreatePhonebookEntry actually only pulls up the wizard so that you can do it manually.  Pretty pointless.

Here are some very general info on API's in VB.  http://www.developer.com/net/vb/article.php/610261

Here is specific info on the RasSetEntryProperties API http://home.iprimus.com.au/billmcc/PlatformVB/dun/rassetentryprops.htm and how to create the type structure in VB is at the bottom of this page.  http://home.iprimus.com.au/billmcc/PlatformVB/dun/rasentry.htm

Without understanding API's this would probably not be the Function you'd want to start with.  Its a pretty complex underlying structure.
0
 

Author Comment

by:amcurso
ID: 20441587
asawatzki - Thank you for the time. I think you have pointed me to the right direction now.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For a while, I have wanted to connect my HTC Incredible to my corporate network to take advantage of the phone's powerful capabilities. I searched online and came up with varied answers from "it won't work" to super complicated statements that I did…
Let’s list some of the technologies that enable smooth teleworking. 
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now