#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0

    Help with Website Login App


    using VB 2005 Express

    Hello, I am having some problems programming a website login app.

    Some sites can use the "GET" method which is fine. I'm looking for a way to use the "POST" method.

    I need my program to be able to open a web browser and run this html code:

    Code:
    <form method="post" action="https://www.***.com/LogIn.php">
    <input type="hidden" maxlength="272" value=" [vb inserted username] " name="newuid">
    <input type="hidden" maxlength="60" value=" [vb inserted password] " name="password1">
    <input type=submit name=submit value="  Continue  ">
    <input type="hidden" name="action" value="login">
    </form>
    Then submit it, to login to the site. If anyone can please help me, that would be great. If anyone has an alternative way to obtain the same goal, that would be great too.

    I am also willing to supply free hosting services for the person who can help make this possible. Thank you.

    -BasicDev
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0
    I can't beleive that anyone here doesn't know how to do this, or at least point me in the right direction?

    Oh, for those poeple who are wondering why I need a program to login to a website; its simple. I own a hosting company and would like to offer my clients an easy way to login to their account and control panel.
  4. #3
  5. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,440
    Rep Power
    4539
    I can't beleive that anyone here doesn't know how to do this, or at least point me in the right direction?
    I can Because you probably can't, unless you can find some spiffy server-side code that can extract posted fields and turn that into a windows login. Or if IIS maybe there is some ISAPI app or something. In any case, the VB forum might not be the best place for this question, but since I don't think you can do what you want, I don't know where to aim you.
    Last edited by Doug G; March 12th, 2008 at 08:51 PM.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    Piece of cake. All you need to do is explore how the MSHTML object works. Create yourself a browser object, then use the Navigate method to go to the website and then set various fields on the form and send a click to the submit button. I have code to do this in Python already, but the same could be done in VB as well.

    Comments on this post

    • BasicDev agrees : Good Job
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,440
    Rep Power
    4539
    Originally Posted by Scorpions4ever
    Piece of cake. All you need to do is explore how the MSHTML object works. Create yourself a browser object, then use the Navigate method to go to the website and then set various fields on the form and send a click to the submit button. I have code to do this in Python already, but the same could be done in VB as well.
    But how do you turn that posted data into IIS/windows authentication? I don't know of any way to pass credentials to IIS for login other than the old way of passing through the URL.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  10. #6
  11. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    The OP is trying to post a web-form to authenticate, not a HTTP authentication. This is how hotmail, gmail, yahoo etc. do it. The key is to be able to navigate a browser window and post the form.

    At one time it was possible to do HTTP authentication by navigating to http://userassword@www.domain.com/ but IE has removed that for a while.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0
    I have found and tested this class and it works great!

    Thank you for your support in helping me find a solution.

    Also, this doesn't require the framework to be installed so it will make my package smaller for download

    Code:
    Public Class Form1
    
     
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            ' Part 1: Use WebBrowser control to load web page
    
            WebBrowser1.Navigate(http://blahblah.com/Login.php)
    
    
        End Sub
    
     
    
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    
            ' Part 2: Automatically input username and password
    
            Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
    
     
    
            For Each curElement As HtmlElement In theElementCollection
    
     
    
                Dim controlName As String = curElement.GetAttribute("name").ToString
    
     
    
                If controlName = "newuid" Then
    
     
    
                    ' curElement.GetAttribute("Value")
    
     
    
                    curElement.SetAttribute("Value", My.Settings.username)
    
     
    
                ElseIf controlName = "password1" Then
    
     
    
                    curElement.SetAttribute("Value", My.Settings.password)
    
     
    
                End If
    
     
    
            Next
    
     
    
            ' Part 3: Automatically click the Login button
    
            Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
    
            For Each curElement As HtmlElement In theWElementCollection
    
                If curElement.GetAttribute("value").Equals("Login") Then
    
                    curElement.InvokeMember("click")
    
                    ' javascript has a click method for we need to invoke on the current submit button element.
    
                End If
    
            Next
    
        End Sub
    
    End Class
    Update:

    The only problem with this is, I have to use the build-in web browser (WebBrwoser1) and cannot have it open in their own favorite browser. Could this still be achived from an external browser?
  14. #8
  15. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,440
    Rep Power
    4539
    Originally Posted by Scorpions4ever
    The OP is trying to post a web-form to authenticate, not a HTTP authentication. This is how hotmail, gmail, yahoo etc. do it. The key is to be able to navigate a browser window and post the form.

    At one time it was possible to do HTTP authentication by navigating to http://userassword@www.domain.com/ but IE has removed that for a while.
    OK, I thought all along the goal was to cause IIS to authenticate, not just how to post a form from VB
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo