none
Excel 2010 VBA WinHttpRequest saved Credentials - where? RRS feed

  • Question

  • I wrote the following code to get the innerHTML text of a website:

    Public Function GetInnerHtmlBody(ByVal Url As String) As HTMLDocument
        Dim ResponseDocument As New HTMLDocument
    
        Dim MyRequest As New WinHttpRequest
        With MyRequest
            .SetTimeouts 5000, 5000, 5000, 5000
            .SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "<PROXY_SERVER_IP>:<PORT>", "*.domain.com"
    
            .Open "GET", Url, False
    
            '// Authentication for the proxy server
            '.SetCredentials "<USERNAME>", "<PASSWORD>", CREDENTIALS_FOR_PROXY
    
            .Send
    
            '// Debug
            MsgBox .ResponseText, vbInformation, .StatusText & " - " & .Status
    
            ResponseDocument.body.innerHTML = .ResponseText
        End With
    
        Set GetInnerHtmlBody = ResponseDocument
    End Function

    As you can see the line .SetCredentials is commented out. This line was only needed once to authenticate with the proxy server but now it seems like the login credentials were saved, because even if i exlude the row the code successfully retrieves the html code of the given website.

    I restartet my computer and cleared the whole IE cache but the code still works.

    1. My question is now where are the Credentials saved?

    I also checked cmdkey /list -> It's empty. I tryed to use the system default proxy before i entered the credentials but it doesn't work. The proxy settings are "normally" coming from a *.pac file which is configured to use in the

    IE -> Settings -> Connection -> LAN -> Script.

    I also checked the GET request using fiddler: Proxy-Connection: Keep-Alive as well as User-Agent: Mozilla/4.0



    Friday, December 5, 2014 3:21 PM

All replies

  • If all else fails, always check the Windows Registry.

    Friday, December 5, 2014 5:26 PM
  • To be more closely - at which registry key ?
    Monday, December 8, 2014 6:33 AM
  • Hi FireEmerald,

    According to your description, this issue is more related to VBA. We will move it to VBA forum for better solutions.

    On the other hand, you could check it in Credential Manager.

    1. Open Control Panel
    2. Select User Accounts->Credential Manager

    Best Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 8, 2014 7:24 AM