Solved

Establishing an internet connection

Posted on 2000-04-07
20
256 Views
Last Modified: 2013-12-03
Hi all,

I need to be able to establish an internet (DUN) connection from my program. The program does not have to download anything, or otherwise use the internet connection: it merely has to establish a connection for the sake of establishing a connection.

It must work whether the EU uses IE (3+) or Netscape (3+), and if possible should work with AOL as well (though I don't know anything about AOL, so I'm not even sure if this is possible - ?).

Also, I can't use MFC or any other libraries (unless they're small and inexpensive) -- just C[++].

Thank you so much,
Stephen
0
Comment
Question by:semck
  • 11
  • 8
20 Comments
 
LVL 2

Expert Comment

by:mnguyen021997
Comment Utility
can you rely on dun ras being installed?  if so, then just make a ras connection and talk PPP.  
0
 

Author Comment

by:semck
Comment Utility
Thanks, mnquyen. Yes, I can probably rely on dun ras being installed. The thing is, I don't know HOW to make a RAS connection on the default Dial-Up server. (I don't know how to make a RAS connection at all).

Thanks,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
RasDial() is the API to use to initiate a RAS/DUN connection.
0
 

Author Comment

by:semck
Comment Utility
Hi jhance,

Thanks for the answer. Unfortunately, RasDial() takes some parameters that my program probably will not be able to provide -- username, password, and phone number.

You see, I want to be able to call up the automatic dial box of the browser, which already knows all of that information. (If the user has to click "Connect" or something on that box, that's no big deal.) The problem is, I won't know beforehand what browser is being used.

I wouldn't mind using RasDial(), except I know of no way to get the username, password, and phone number of the ISP, except asking the user, which is unacceptable.

Thank you,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
Two things you need here:

1) Determine the default internet connection.

2) Dial the connection successfully.



To accomplish #1, you must have IE installed and configured as this is an IE setting, not Windows standard.

Read the default DUN connection from:

HKEY_CURRENT_USER\RemoteAccess

and the value there called:

InternetProfile


Once you have that, you're ready to dial.  The function RasDial is defined as:

DWORD RasDial(
  LPRASDIALEXTENSIONS lpRasDialExtensions,
                          // pointer to function extensions data
  LPCTSTR lpszPhonebook,  // pointer to full path and filename of
                          // phone-book file
  LPRASDIALPARAMS lpRasDialParams,
                          // pointer to calling parameters data
  DWORD dwNotifierType,   // specifies type of RasDial event handler
  LPVOID lpvNotifier,     // specifies a handler for RasDial events
  LPHRASCONN lphRasConn   // pointer to variable to receive
                          // connection handle
);
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
>I wouldn't mind using RasDial(), >except I know of no way to get the >username, password, and phone number >of the ISP, except asking the user, >which is unacceptable.

You must know the users logon name and password to establish a connection using RasDial.  On Win9x it's stored using lame "encryption" in the users's pwl file.  There are many resources that describe this format and how to hack it.

On NT the data is stored more securely.

You can use the information in the following KB article to initiate a DUN connection from a Win9x computer via a system call using the (hopefully) stored username and password for the DUN connection.

On NT, you can accomplish the same thing with the RasDialDlg function.


From the remarks section in RASDIALPARAMS:

Remarks

The szUserName and szPassword strings are used to authenticate the user's access to the remote access server.

Windows NT/2000: RAS does not actually log the user onto the network. The user does this in the usual manner, for example, by logging on with cached credentials prior to making the connection or by using CTRL+ALT+DEL, after the RAS connection is established.

If both the szUserName and szPassword members are empty strings (""), RAS uses the user name and password of the current logon context for authentication. For a user mode application, RAS uses the credentials of the currently logged-on interactive user. For a Win32 service process, RAS uses the credentials associated with the service.

Windows 95: RAS uses the szUserName and szPassword strings to log the user onto the network.

Windows 95 cannot obtain the password of the currently logged-on user, so if both the szUserName and the szPassword members are empty strings (""), RAS leaves the user name and password empty during authentication



Neither is particularly clean since you're dependent on a valid DUN/RAS connection and a preconfigured username and password.  

Why is your application having to be so sneaky?  Why not just query the user for the required information at install and save it away for later use?
0
 

Author Comment

by:semck
Comment Utility
Thanks jhance,

I've got IE (version 5.0), but I don't have the "Internet Profile" value in my registry.

Also, are you sure that Netscape has no such thing as a default connection? How do Netscape users connect to the internet?

Finally, even knowing the correct connection to call would not give me all the information I need to call it. (If everyone were kind enough to use IE4+, I could just use InternetAutoDial(0,0). Sigh. )

Thanks,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
Actually, now that I think about it, InternetDial may be what you're looking for....



DWORD InternetDial(
    IN HWND hwndParent,
    IN LPTSTR lpszConnectoid,
    IN DWORD dwFlags,
    OUT LPDWORD lpdwConnection,
    IN DWORD dwReserved
);
0
 
LVL 32

Accepted Solution

by:
jhance earned 1000 total points
Comment Utility
>I've got IE (version 5.0), but I don't
>have the "Internet Profile" value in
>my registry.

Are you sure you looked in the right place and you have a default connection defined?


>Also, are you sure that Netscape has
>no such thing as a default connection?
>How do Netscape users connect to the
>internet?

I'm sure.  If Netscape autodials, it's due to the IE auto dial setup.  Pretty ironic that Netscape uses an IE4 feature to autodial.
0
 

Author Comment

by:semck
Comment Utility
Adjusted points from 700 to 1000
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:semck
Comment Utility
Hi jhance,

Thanks for the suggestion. There is nothing I would like better than to use InternetDial, but it works only with IE4.

I really don't want to get into hacking passwords.

>Why is your application having to be >so sneaky?  Why not just query the >user for the required information at >install and save it away for later >use?

Well, it's not that I'm being 'sneaky' (at least that's not my purpose), but this is supposed to be super-convenient. Of course, if nothing else works, then I will have to query the user for his password, but I'd rather do it automatically if possible.

I appreciate the time you're taking with this.

Thanks,
Stephen



0
 

Author Comment

by:semck
Comment Utility
>I'm sure.  If Netscape autodials, it's >due to the IE auto dial setup.  Pretty >ironic that Netscape uses an IE4 >feature to autodial.

Very interesting indeed, lol. I'll mention this to my customer (he's the one who wants this in the first place).

Yes, I'm sure that I have a default connection and that I looked in the right place (HKEY_CURRENT_USER\RemoteAccess).

Thanks yet again,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
OK, if Netscape will autodial an internet connection there MUST be someplace to configure it, right?

So tell me where it is configured?

I'll tell you where.  Right-click on Internet Explorer select Properties.

This opens the Internet Properties dialog.  There choose the Connections tab.  You must choose "Dial whenever" or "Always dial" and then select one of the connections.  Click "Set Default".

You can add points all day but it won't change the facts.
0
 

Author Comment

by:semck
Comment Utility
Appologies. I have now found the "default" registry entry. I was looking for a subkey instead of a named value. Sorry. :-|

Thanks,
Stephen
0
 

Author Comment

by:semck
Comment Utility
I'm sorry jhance,

I increased the points before I saw your remark about Netscape using IE.

I'll discuss things with my customer, then I'll probably go ahead and accept one of your comments as an answer.

Thank you for all of your help,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
By the way, the reason I'm so positive about this is that I've been through this with a customer of mine.

He wanted their app to be able to use an existing DUN connection independent of the user's username/password but without any intervention.

I explored this in depth and even wrote a dialer that used password hacked out of the pwl file.  We finally rejected that for 2 reasons, first there is no assurance that MS won't change the pwl format in some future patch and second, they didn't like the potential liability of their program "hacking" password files on their customer's computers.

We ended up not using any of the existing DUN connection either since there is no assurance that any of them are actually workable.  The program just asked the user for his ISP information during the installation and used that to build a "private" DUN connection using RasSetEntryProperties.  Then it used RasDial to call that connection.

If there were problems, then the customer support could freely deal with and modify the "private" connection without having to worry about messing with the users other connections.
0
 

Author Comment

by:semck
Comment Utility
Hi,

OK, thanks for the info.

I should go ahead and explain my request a bit, too. My program needs the modem, and for that reason it disconnects the user's internet connection, if there is one. After it's done with the modem, it then has to reconnect the user to the internet (so as to be polite).

Thanks,
Stephen
0
 

Author Comment

by:semck
Comment Utility
Many thanks, jhance. I appreciate all your time and trouble here.

All the best,
Stephen
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
You may want to use RasEnumConnections instead of the default information.  Since you are dealing with an existing connection, you can't assume that the active connection is the default one.

RasEnumConnections will give you the active one.  It's possible that there is more than one, but it's unlikely.  You can check the szDeviceName in the return RASCONN struct and see if this is the one on your modem line.
0
 

Author Comment

by:semck
Comment Utility
Right-O, thanks for the info.

All the best,
Stephen
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

763 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

13 Experts available now in Live!

Get 1:1 Help Now