auto login to web application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vaskafdt
    New Member
    • Mar 2008
    • 1

    auto login to web application

    good day.

    i am trying to make an application that logs in to a web application that sits on a server, puts in the user name and password, and sends an email notification(th at part is not a problem) if the log in failed.

    i can code somewhat on vb6 and i was wondering how should i approach such a project.

    i tried to set up a web browser using Microsoft internet component, but i got stumped as to how i send commands into the application itself. and I'm not sure that it is in fact the right track

    if someone could advice as to what tools/component i should use to such a project or if should abandon vb6 completely and try it on something else(hopefully not).

    if someone encountered a tutorial to something similar in the past a link would also be much appreciated.

    thanks in advance and any comment is welcome.
  • douglandmesser1
    New Member
    • Apr 2008
    • 3

    #2
    Hi there. Well, I can log you into the web server. From there you're on your own. I worked on this for a while and managed to upload/download using VB6. It's not too easy, but it works. I put some code below:

    Const scUserAgent = "vb wininet"
    Const INTERNET_SERVIC E_FTP = 1
    Const INTERNET_OPEN_T YPE_DIRECT = 1
    Const INTERNET_FLAG_P ASSIVE = &H8000000
    Const FTP_TRANSFER_TY PE_BINARY = 0
    Const FILE_ATTRIBUTE_ ARCHIVE = &H20
    Private Declare Function InternetOpen Lib "wininet.dl l" Alias "InternetOp enA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
    Private Declare Function InternetConnect Lib "wininet.dl l" Alias "InternetConnec tA" (ByVal hInternetSessio n As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
    Private Declare Function FtpGetFile Lib "wininet.dl l" Alias "FtpGetFile A" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttri butes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
    Private Declare Function FtpPutFile Lib "wininet.dl l" Alias "FtpPutFile A" (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
    Private Declare Function InternetCloseHa ndle Lib "wininet.dl l" (ByVal hInet As Long) As Integer


    Dim hOpen&, hConn&
    Dim lRes As Long
    hOpen = InternetOpen(sc UserAgent, INTERNET_OPEN_T YPE_DIRECT, vbNullString, vbNullString, 0)
    hConn = InternetConnect (hOpen, "ftp.thelwcf.co m", "21", "username", "password", INTERNET_SERVIC E_FTP, INTERNET_FLAG_P ASSIVE, 0)
    lRes = FtpPutFile(hCon n, "localfile" , "remotefile ", FTP_TRANSFER_TY PE_BINARY, 0&)
    InternetCloseHa ndle hConn
    InternetCloseHa ndle hOpen

    Dim hOpen&, hConn&
    Dim lRes As Long
    hOpen = InternetOpen(sc UserAgent, INTERNET_OPEN_T YPE_DIRECT, vbNullString, vbNullString, 0)
    hConn = InternetConnect (hOpen, "ftp.thelwcf.co m", "21", "username", "password", INTERNET_SERVIC E_FTP, INTERNET_FLAG_P ASSIVE, 0)
    lRes = FtpGetFile(hCon n, "remotefile ", "localfile" , False, FILE_ATTRIBUTE_ ARCHIVE, FTP_TRANSFER_TY PE_BINARY, 0&)
    InternetCloseHa ndle hConn
    InternetCloseHa ndle hOpen

    This code will get you uploading and downloading and passing credentials to the web server. Hopefully you can modify it to your needs. Hope this helps.

    Comment

    • gobblegob
      New Member
      • Dec 2007
      • 133

      #3
      i am trying to make an application that logs in to a web application that sits on a server, puts in the user name and password, and sends an email notification(th at part is not a problem) if the log in failed.


      Hi vaskafdt,
      its accually quite easy, you just have to find the exact name of the
      username and password textbox's and submit button which can be difficult
      try this :
      only need a webbrowser
      Code (vb 6)
      Code:
      'declare this
      Dim Website As String
      
      Private Sub Form_Load()
      
          Website = "http://www.mysite.com.au/site/user/login" 'this is the loginpage 
          Username = "mymail@somemail.com"
          Password = "mypassword"
      
          WebBrowser1.Navigate (Website)
      
      End Sub
      
      
      
      Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
      On Error Resume Next
          If URL = Website Then
                    'on the page find the username textbox name
              WebBrowser1.Document.All.Item("edit-name").Value = Username
                    'and find the password texbox name
              WebBrowser1.Document.All.Item("edit-pass").Value = Password
                    'also find the submit button name
              WebBrowser1.Document.All.Item("edit-submit").Click
      Else
          Exit Sub
          End If
      
      End Sub
      let us know how you go


      GobbleGob.

      Comment

      Working...