PPPOE Dialer

Apr 9, 2010 at 11:57 PM

Hi,

Can i create a new PPPoE Dialer using DotRAS in Vista and Win7. And how can i check whether a dialer is present already or not.

 

Looking forward for a quick and positive reply.

Coordinator
Apr 10, 2010 at 12:28 AM

Not really sure what you're asking, the RasDialer component in the project just interfaces with the RAS API in Windows. Windows handles all the heavy lifting, the project just tells it what to do.

Apr 10, 2010 at 2:09 AM

 PPPoE is basically a Broadband (WAN MiniPort PPPoE) Connection. In VB6 i made an application that can do almost anything with PPPoE in WinXP.  But for vista and win7 i am really having trouble creating a Broadband Dialer. I only need to create it, rest i wil do with a simple command "rasdial" to login and other functions.

When you make a new connection , the type i am interested in is Broadband, not VPN. If in anyway this is possible, please help me out.

Coordinator
Apr 10, 2010 at 3:43 AM

First I'd like to point out this is a .NET project, it will not work with VB6 until I make it accessible to COM. I don't have that done yet, but I do have plans in the future to take a look at making that work.

It sounded like you were trying to make a driver or something in your initial question. Let me also say I've never specifically tried to do broadband with it, but I have no doubts the project will be able to handle it. I don't have hardware to test every scenario for every possible combination of what Windows is capable of using, all I do is wrap what Windows gives us and let it handle the work. From what I can tell, what you're trying to do is tied more to the entry configuration than the way the connection is dialed. You'll need to use a WINXP or later build since that's the first version of Windows that supports broadband connections. That assembly will work on every operating system, so it's not specifically tied to work only with Windows XP. You can read more in the Getting Started section under documentation more information about platform interoperability with the project. Right now there are no helper methods to assist with creation of Broadband based connections so you're going to have to manually create the entire entry from scratch. It's not hard, you just have to know what to set to get it to work. The best way I can say to do this, would be to create a connection in Windows, open the phone book in an application, and copy down all the settings on the RasEntry object and replicate that in code.

Now down to the important part and probably what you're interested in the most.... THE CODE!

' Create the entry that will be added to the phone book for the connection.
Dim entry As New RasEntry("Broadband Connection")
entry.Device = RasDevice.GetDeviceByName("(PPPOE)", RasDeviceType.PPPoE, false)
entry.EntryType = RasEntryType.Broadband
entry.FramingProtocol = RasFramingProtocol.Ppp
entry.NetworkProtocols = RasNetworkProtocols.IP
entry.RedialCount = 3
entry.RedialPause = 60
entry.PhoneNumber = string.Empty
entry.Options = RasEntryOptions.RemoteDefaultGateway Or _
    RasEntryOptions.ModemLights Or _
    RasEntryOptions.SecureLocalFiles Or _
    RasEntryOptions.RequirePap Or _
    RasEntryOptions.PreviewUserPassword Or _
    RasEntryOptions.ShowDialingProgress Or _
    RasEntryOptions.RequireChap Or _
    RasEntryOptions.RequireMSChap2
entry.ExtendedOptions = RasEntryExtendedOptions.SecureFileAndPrint Or _
    RasEntryExtendedOptions.SecureClientForMSNet Or _
    RasEntryExtendedOptions.DoNotNegotiateMultilink Or _
    RasEntryExtendedOptions.DoNotUseRasCredentials Or _
    RasEntryExtendedOptions.Internet Or _
    RasEntryExtendedOptions.DisableNbtOverIP Or _
    RasEntryExtendedOptions.ReconnectIfDropped

' Now that the entry has been made, add it to the phonebook.
Dim pbk As New RasPhoneBook
pbk.Open()
pbk.Entries.Add(entry)

' Dial the connection
Dim dialer As New RasDialer
dialer.EntryName = "Broadband Connection"
dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers)
dialer.Dial() ' You can use the DialAsync here as well.

I did find there was an issue with the 1.1 SDK which will not allow empty phone numbers that a broadband connection uses, give me a bit and you'll be able to get the latest source code and use that to fix the problem.

Apr 10, 2010 at 4:08 AM
Edited Apr 10, 2010 at 4:30 AM

Dear Jeff,

You are the best. Yes the code worked, but the issue that you stated about phone number is there. I am right now also working for resolve it with any tweak, if it works i will let you know.

I will be looking forward for new SDK that can allow empty phone number.

I am very thankful to you Mr. Jeff for helping me out.

And yes when my final application will be completed, i will mail that to you.

I found a way, it is very basic.

entry.PhoneNumber = " "

This is what i have used, and it works, however strings.emtpy dont work.

<font size="2">

Anyways, now i am continuing on my application, and when it will be finished, i will make it availble for everyone.

</font>

 

 

Coordinator
Apr 10, 2010 at 5:10 AM
Edited Apr 10, 2010 at 5:11 AM

So I finished the update and I also added a new feature for you that should help creating the entry so you don't need to do it manually. All that code I showed you earlier to create the new entry can be replaced with:

Dim entry As RasEntry = RasEntry.CreateBroadbandEntry("Broadband Connection", RasDevice.GetDeviceByName("(PPPOE)", RasDeviceType.PPPoE)

Also, keep in mind you don't need to use the rasdial.exe that you've been forced to previously. If you're using DotRas you can use the RasDialer component to handle dialing the connections, it also allows for both synchronous and asynchronous dialing of connections and even has event notifications as the state of the connection changes during dialing! Don't worry about mailing me your project though I appreciate the offer.

When you get a chance, download the latest copy of the SDK (57456 or later) from the source code tab. Everything should work now without doing any workarounds.

Easy way to compile the project is from a Visual Studio command prompt, run the make.bat from trunk and choose option 1 for the non-official release when prompted. That will handle creating all of the assemblies for you, just grab whichever assembly you want from the Output\Bin folder relative to where you have the project extracted.

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

Edit: Had to fix a small problem my VB.NET example in the post.

Apr 10, 2010 at 5:21 PM

Hi,

Thanks allot Jeff. Where can i download this new SDK, i looked under the download section but did not find any new SDK. Kindly send me the link, so that i can download and continue using it.

Coordinator
Apr 10, 2010 at 5:49 PM

Downloads only contains official releases of the project. You need to click the Source Code tab at the top, and click the Download link at the right side of the page. You can follow the rest of my instructions once you accept the license agreement by clicking Accept and then decompressing the zip file.

Apr 10, 2010 at 5:54 PM

Dear Jeff,

Thanks to you my application for Vista and Win7 is now complete. It is not a fully integrated Broadband dialer, but it is what I wanted. It does all the thigs that i needed.

Thanks again.

Coordinator
Apr 10, 2010 at 5:57 PM

You're welcome, glad to see the project did what you needed it to do. If you have any other questions, feel free to ask.

Apr 11, 2010 at 1:07 AM

Dear Jeff,

I wanted to ask onething, If i use DotRAS to dial my PPPoE connection, can i specify username and password (like txtid.text and txtpass.text) use these variabled to dial. If yes then where in the code below to use them. If i get invalid username or password error will it prompt me or for that i have to do something else, can it show the whole process in a text box with multiline yes.

I hope i am not annoying you.

Dim dialer As New RasDialer
dialer.EntryName = "Crystal Networks"
dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers)
dialer.Dial() ' You can use the DialAsync here as well.
Coordinator
Apr 11, 2010 at 3:21 AM

Well, if you're dialing synchronously the dialer will throw an error if the connection was unsuccessful, if you're dialing asynchronously (the DialAsync method) the component raises an event when the connection attempt completes with event information indicating the status of the connection. As for your question about the credentials, you just need to set the credentials property on the dialer for it to pass them to the connection. You might want to consider watching the C# screencast I did on YouTube, there is a link on the home page of the project. The principles are the same, it's just making a VPN connection instead of a broadband connection. The connection type doesn't matter, how it works is what you're interested in. Keep in mind the SDK between 1.0 and 1.2 is slightly different.

Feb 14, 2011 at 12:52 PM
Edited Feb 14, 2011 at 1:14 PM

hi

my name is Vahid Nariman , thanks for jeff & mudasir for comments

how i can type my user & password in 2 text box to use in program to dial ?

"The remote connection was denied because the user name and password combination you provided is not recognized, or the selected authentication protocol is not permitted on the remote access server."

if possible , please send me an PPPOE Connector VB.net codes or SLH .

thanks

Coordinator
Feb 15, 2011 at 2:16 AM

As stated in my previous post, you just need to set the dialer.Credentials property on your dialer instance to provide credentials for the dialer to use.

Feb 15, 2011 at 8:15 AM
Edited Feb 15, 2011 at 11:46 PM

Mr.mudasir helped me to crate this program to dial PPPOE :

Imports System.Net
Imports System.Net.NetworkInformation
Imports DotRas
Imports Microsoft.Win32

Public Class Form1
    Public entry As RasEntry = RasEntry.CreateBroadbandEntry("Broadband Connection", RasDevice.GetDeviceByName("(PPPOE)", RasDeviceType.PPPoE))
    Public pbk As New RasPhoneBook
    Private connectionHandle As RasHandle
    Public dialer As New RasDialer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        pbk.Open()
        pbk.Entries.Clear()
        pbk.Entries.Add(entry)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        dialer.DialAsyncCancel()
        dialer.Credentials = New NetworkCredential(phn.Text.ToString(), Pastxt.Text.ToString())
        dialer.EntryName = "Broadband Connection"
        dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers)
        Try
            dialer.Credentials = New NetworkCredential(phn.Text.ToString(), Pastxt.Text.ToString())
            dialer.Dial()
        Catch ex As Exception
            '  Eventstxt.AppendText(ex.Message.ToString & Chr(10))
            Eventstxt.AppendText(ex.ToString & Chr(10))
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If (dialer.IsBusy) Then
            dialer.Dispose()
        Else
            Dim Mypbk = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.AllUsers).ToString()
            Dim MyConn As RasConnection = RasConnection.GetActiveConnectionByName("Broadband Connection", Mypbk)
            If (MyConn IsNot Nothing) Then
                MyConn.HangUp()
                Eventstxt.AppendText("Disconnected on User Request!")
            End If
        End If
    End Sub
End Class

but i cant write dialer change events to Eventstxt , help me please ...