Solved

Creating VPN Connection from VB with user credentials

Posted on 2006-06-13
5
856 Views
Last Modified: 2008-01-09
Hi.

I used the following example to create a VPN connection:

http://www.freevbcode.com/code/Dun_Module.zip

I would now like to create the VPN connection with the username, password and domain preset.

Heres what I have tried so far:

From the CreateNewEntry sub on the form:

------------------------------------------------------------------------------------

Dim typVBRasEntry As VBRasEntry
typVBRasEntry.DeviceName = "WAN MiniPort (PPTP)"
typVBRasEntry.DeviceType = "modem"
typVBRasEntry.fNetProtocols = RASNP_Ip
typVBRasEntry.FramingProtocol = RASFP_Ppp
typVBRasEntry.LocalPhoneNumber = "192.168.0.15"

Dim RASParams As VBRasDialParams
RASParams.UserName = "testusername"
RASParams.Password = "testpassword"
RASParams.Domain = "testdomain"
 
Dim rtn As Long
rtn = VBRasSetEntryProperties("DUN NAME", typVBRasEntry, RASParams)

added to VBRasSetEntryProperties on the Module ---->

CopyStringToByte b(1249), RASParams.UserName, lngStrLen

----------------------------------------------------------------------------------------------

Any help is much appreciated!

0
Comment
Question by:LFMSupport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 500 total points
ID: 16898828
this is fine, in fact ive spent much time in the past messing about with RASAPI and i believe making connections is still best done in there...

However i soon stopped bothering once i realised i can shell out (on 2000 and above) a

cmd /c Rasdial "Connectionname To Dial" Username Password

command. Saved me many an hour going mad in the RASAPI bubble.

go command prompt and do a rasdial /? for even more options...

hth

0
 
LVL 9

Expert Comment

by:lojk
ID: 16898831
I suppose that should read...

cmd /c Rasdial "Connectionname To Dial" "Username" "Password"

Also, just running Rasdial Lists all current Dialup/VPN connections...

0
 
LVL 1

Author Comment

by:LFMSupport
ID: 16900802
I could make that work.

Thanks mate.
0
 
LVL 9

Expert Comment

by:lojk
ID: 16900848
RASAPI is an unpleasant place indeed and its actually quite difficult to control the Windows Interface side of it, you usually end up making your own RAS dialer and calling the connection which is not wholly dissimilar to doing a Rasdial (just means you lose any Win9x compatability)...

If I've saved just *one* tuft of your hair then I'm happy... Thx for points...
0
 
LVL 1

Author Comment

by:LFMSupport
ID: 16901795
You have ;-)

Do you have any idea which parameter/property enables you to show the icon inthe tray when connection??
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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