Results 1 to 10 of 10

Thread: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

  1. #1

    Thread Starter
    Lively Member cyberd's Avatar
    Join Date
    Jul 2008
    Location
    GREECE
    Posts
    108

    Lightbulb Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    Hi - first time posting at this forum:wave: ,

    i want to make a simple application - i tried to search the forum but nothing found...

    Automatically Login to a Protected Site (Using Authentication Dialog) like routers... or protected directory (.htaccess)


    Well as i am saying - i would like to connect with simple way like from address bar or making vb program (i have many wifi aps and i want to control them from a program in vb using webbrowser or winhttp)

    i know that at ftp you can write at address bar of ie:

    old days i think that you can use it too for http:// but - many times i tried and get nothing... :-(

    So i am familiar with VB 6 / winhttp / webbrowser controls and if someone can help me with this prob i have will be cool!!!!

    Thanx in advance


    ps: @ moderators - i didn;t know acctually where to post this thread - i hope it will be at right section...
    Last edited by MartinLiss; Aug 22nd, 2008 at 09:59 AM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    Welcome to the Forums.

    Are you going to be using VB6 for this then? If so I can move this thread to the Classic VB and Earlier forum.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member cyberd's Avatar
    Join Date
    Jul 2008
    Location
    GREECE
    Posts
    108

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    yes,

    simple Classic VB6,

    and sorry - please reply me the new link.

    Thanx

  4. #4

    Thread Starter
    Lively Member cyberd's Avatar
    Join Date
    Jul 2008
    Location
    GREECE
    Posts
    108

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    someone please ?

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    Thread Moved

    You can use the Inet control and pass the login information so you can download the page. Not sure what exactly you want to do after login.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Lively Member cyberd's Avatar
    Join Date
    Jul 2008
    Location
    GREECE
    Posts
    108

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    inet control can pass information at authentication dialog... is it possible ?
    can i have an example... ?

    - what i want to do?
    i want for example resetting my Access Point (applying dchp for dlink 900ap - reset it fast) - every 1 hour ..

    can u give me one example - please - thanks in advance.

  7. #7

    Thread Starter
    Lively Member cyberd's Avatar
    Join Date
    Jul 2008
    Location
    GREECE
    Posts
    108

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    someone can help ?

  8. #8

  9. #9
    Addicted Member pcuser's Avatar
    Join Date
    Jun 2008
    Posts
    219

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    .htaccess uses base 64 encoding.

    Add two command buttons and a winsock control to a form:

    Code:
    Option Explicit
    
    Dim MyIP
    Dim MyPort
    Dim MyUsername
    Dim MyPassword
    Dim MyCGI
    
    
    Private Sub Command1_Click()
        Unload Me
    End Sub
    
    Private Sub Command2_Click()
        Winsock1.Close
        Winsock1.RemotePort = MyPort
        Winsock1.RemoteHost = MyIP
        Winsock1.Connect
    End Sub
    
    Private Sub Form_Load()
        MyIP = "192.168.0.1"
        MyPort = "82"
        MyUsername = "username"
        MyPassword = "password"
        MyCGI = "/cgi/some.cgi?params"
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Winsock1.Close
    End Sub
    
    Private Sub Winsock1_Connect()
        With Winsock1
            .SendData ("GET " & MyCGI & " HTTP/1.1" & vbCrLf)
            .SendData ("Accept: */*" & vbCrLf)
            .SendData ("Accept-Language: en-us" & vbCrLf)
            .SendData ("Accept-Encoding: gzip, deflate" & vbCrLf)
            .SendData ("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" & vbCrLf)
            .SendData ("Host: HostNameGoesHere" & vbCrLf)
            .SendData ("Connection: Keep-Alive" & vbCrLf)
            .SendData ("Authorization: Basic " & Encode64(MyUsername & ":" & MyPassword) & vbCrLf)
            .SendData (vbCrLf)
        End With
    End Sub
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Dim GotIt As String
        Winsock1.GetData GotIt
        MsgBox GotIt
    End Sub
    
    Function Encode64(InputStr As String) As String
        Dim State As Integer
        Dim i As Integer
        Dim Base64
        Dim current As Integer
        Dim old As Integer
        Dim first_new As String
        Dim second_new As String
        Dim Output As String
        
        Base64 = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", _
                       "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", _
                       "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", _
                       "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", _
                       "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/")
        
        For i = 1 To Len(InputStr)
             State = State + 1
             Select Case State
             Case 1
                 current = Asc(Mid(InputStr, i, 1))
                 first_new = Base64((Int(current / 4) And &H3F))
                 Output = Output & first_new
             Case 2
                 current = Asc(Mid(InputStr, i, 1))
                 first_new = Base64((((old * 16) And &H30) Or ((Int(current / 16) And &HF))))
                 Output = Output & first_new
             Case 3:
                 current = Asc(Mid(InputStr, i, 1))
                 first_new = Base64((((old * 4) And &H3C) Or ((Int(current / 64) And &H3))))
                 second_new = Base64((current And &H3F))
                 Output = Output & first_new & second_new
                 State = 0
             End Select
             old = current
         Next
         Select Case State
         Case 1
             first_new = Base64(((old * 16) And &H30))
             Output = Output & first_new & "=="
         Case 2
             first_new = Base64(((old * 4) And &H3C))
             Output = Output & first_new & "="
         End Select
         Encode64 = Output
    End Function

  10. #10
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...

    this is something i think i need hmmm...

    ill try this .. thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width