Create a Dialup Entry

Jan 26, 2010 at 9:49 AM
Edited Jan 26, 2010 at 9:51 AM

Good Day Everyone,

 

'Dim entry As RasEntry = RasEntry.CreateVpnEntry(EntryName, IPAddress.Loopback.ToString(), RasVpnStrategy.Default, RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn))

Dim entry As RasEntry = RasEntry.CreateDialUpEntry("Dialup", "9998888", RasDevice.GetDeviceByName("(PPP)", RasDeviceType.Generic))

 

From the sample code that I have download, I also want to be able to create a dialup entry and be able to view it in the list of connections.

 

but there was an error in the returned rasdevice, may I know what type of rasdevice and parameters should I put? (RasDevice.GetDeviceByName("(PPP)", RasDeviceType.Generic))

 

 

the device is a 56k modem :D

 

TIA,

elitefox

 

Coordinator
Jan 26, 2010 at 2:43 PM

"(PPTP)" and RasDeviceType.Vpn is used because the device name is actually "WAN Miniport (PPTP)" and the device type is "vpn" on english versions of Windows. I used "(PPTP)" in the video because that's the only part of the device name that's constant on all languages.

For dialup connections the device name would be the name of your modem as reported by the device manager, with RasDeviceType.Modem as the device type.

Take a look at the collection returned from RasDevice.GetDevices() and you'll see what I'm talking about. The GetDeviceByName method just iterates through the collection returned from GetDevices() and finds which device you want. I added those methods to reduce the amount of code everyone was having to add to their applications because every app that uses DotRas needs to find a single device from the collection at some point.

If you have any other questions, feel free to ask.

- Jeff

Jan 27, 2010 at 12:30 AM

Thank you very much... it worked.

 

You really gave me wonders with you dotras project :D

I thought (PPTP) was the name of the protocol lol

so I googled what protocol is Dial up and ended up with an error :D

This is the sample modem :D

U.S. Robotics 56K Faxmodem USB

 

The only problem is if I get the user the right to create a modem, what parameter will I pass onto it?

Does .net have a class to list all the modem device e.g. U.S. Robotics 56K Faxmodem USB?

Sorry if this goes out of your project scope.

 

Thanks Again,

elitefox

Jan 27, 2010 at 2:36 AM

The OS I am using is Windows 7

 

Error: The system could not find the phone book entry for this connection.

This is what I get when I try to dial the connection, VPN or dialup?

The connection does exist and I can dial it manually

I opened the sample project and the same problem occurs, is there something I am lacking?

 

Private Sub btnDial_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDial.Click

        ' me button will be used to dial the connection.
        Me.Dialer.EntryName = Me.AllUsersRasPhoneBook.Entries(cboConnections.SelectedIndex).Name
        Me.Dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers)


        Try
            Me.Dialer.Dial(New NetworkCredential(txtUsername.Text.ToString(), txtPassword.Text.ToString()))
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

 

TIA,

elitefox

Coordinator
Jan 27, 2010 at 4:25 AM

"The only problem is if I get the user the right to create a modem, what parameter will I pass onto it? Does .net have a class to list all the modem device e.g. U.S. Robotics 56K Faxmodem USB?"

You can use GetDeviceByType(RasDeviceType.Modem) to find all of the modems installed on the machine. Also, you should avoid using the RasDevice.Create method if possible. It's only exposed because a couple users of mine needed it exposed due to problems with Windows reporting devices that were disconnected and reconnected in certain scenarios. The create method basically means your user is adding a piece of hardware in the machine, which may not exist and thus cause a failure while dialing.

"Error: The system could not find the phone book entry for this connection. This is what I get when I try to dial the connection, VPN or dialup?"

There are two phone books in use by Windows. If you add it to one, and try to dial it from another that error will occur. The network connections window displays both phone books without distinguishing which entries are in which phone book.

- Jeff

Jan 27, 2010 at 7:20 AM

Thank you Again for the quick reply

I will follow you're suggestion not to use RasDevice.Create.

 

I change RasPhoneBookType.AllUsers RasPhoneBookType.user and it work :D

I thought that if I checked the all users can use this connection it will be available in allusers but it seems not :D

 

 

can I have one more question?

 

how can I change the host IP address of VPN?

I tried to create an entry and pass a parameter to entry.ipaddress

RasEntry entry = RasEntry.CreateVpnEntry(EntryName, IPAddress.Loopback.ToString(), RasVpnStrategy.Default,
                RasDevice.GetDeviceByName("(PPTP)", RasDeviceType.Vpn));
 entry.IPAddress = new IPAddress(IPAddressToNumber("192.168.0.1"));

this.AllUsersPhoneBook.Entries.Add(entry);

 

but it didn't have an effect :(

 

Thank you and have a nice day :D

elitefox

Coordinator
Jan 27, 2010 at 3:27 PM

You really should read the SDK, the majority of your questions would have been answered by reading the documentation.

"I thought that if I checked the all users can use this connection it will be available in allusers but it seems not :D"

The phone books used by Windows are file based, "All Users" is actually one of the profile names on the machine, and User would be the profile of the current logged in user. They're stored in completely different physical locations on the machine.

"how can I change the host IP address of VPN?"

You're passing the loopback address into the VPN entry you're creating. IPAddress is the address of the client, not the server. You can change your CreateVpnEntry call to pass in your server name in the second argument. You'd have seen that if you had read the intellisense comments I took the time to put in there, or read the documentation.

You can set it there or through the PhoneNumber property on the object. Yes, I know it's a strange name but that's what Windows calls it so that's what I kept it to avoid confusion.

Jan 29, 2010 at 2:43 AM

Sorry I did read the documentation very lightly... I only read what I think I needed to connect, disconnect and reconnect to another computer since I need to automatic sync between 2 folders.

 

I am grateful that you answered my questions :D

 

Thank you again and have a nice day :D

elitefox

Coordinator
Jan 29, 2010 at 3:23 AM

Glad to hear you got everything working. Have fun on your project!