Solved

Creating VPN Connection from VB with user credentials

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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 (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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

810 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