Solved

Creating VPN Connection from VB with user credentials

Posted on 2006-06-13
5
849 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

14 Experts available now in Live!

Get 1:1 Help Now