Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2008 Apr : HTTP Proxy Credential Retrieval

www.cryer.info
Managed Newsgroup Archive

HTTP Proxy Credential Retrieval

Subject:HTTP Proxy Credential Retrieval
Posted by:"Rich L." (rletsing..@gmail.com)
Date:Tue, 22 Apr 2008 13:07:23 -0700 (PDT)

Greetings,

I have an ActiveX control that uses WinINET. If the browser prompts
for username and password to traverse an outbound proxy, I need to
collect those credentials. This is documented in the MSDN as available
using the InternetQueryOption function. However, despite returning
(great) success the username returned is always empty. Here's the code
snippet.

InternetQueryOption( m_hRequest,
                     INTERNET_OPTION_PROXY_USERNAME,
                     NULL,
                     &cbUsername );
if ( cbUsername ) {
  fSuccess = InternetQueryOption( m_hRequest,
                                  INTERNET_OPTION_PROXY_USERNAME,
                                  pszUsername,
                                  &cbUsername );
  if( fSuccess ) {
    WCHAR bufr[MAX_PATH];
    StringCchPrintf( bufr,
                     MAX_PATH,
                     L"Proxy username[%s] size[%d].",
                     pszUsername,
                     cbUsername);
    MessageBox(NULL, bufr, L"Woot!", MB_OK);
  } else {
    MessageBox(NULL, L"Failed to get username.", L"Drag.", MB_OK);
  }
}

Result is notebox with, "Proxy username[] size[0]." Thanks in advance
for any help.

Sincerely,
Rich L.

Replies:

www.cryer.info
Managed Newsgroup Archive