Reputation: 1581
I am attempting to use WinHttpGetProxyForUrl
where the PAC file specified by WINHTTP_AUTOPROXY_OPTIONS.lpszAutoConfigUrl
requires HTTP basic authentication to access.
Is there some way to cause the regular authentication dialog to popup or to supply username and password to use for the proxy?
Upvotes: 2
Views: 3612
Reputation: 5638
Automatic credential dialog handling is only supported in WinInet. In WinHTTP you have to provide a way to get the user's username and password yourself and pass it to WinHttpSetCredentials
or similar function. I would check for a return value of ERROR_WINHTTP_LOGIN_FAILURE
from WinHttpGetProxyForUrl
and then ask for the user's credentials. At which point you could try either of the following to pass those credentials to WinHTTP:
WinHttpSetOption
with WINHTTP_OPTION_USERNAME
and WINHTTP_OPTION_PASSWORD
to set the username and password and recall WinHttpGetProxyForUrl
.WinHttpGetProxyForUrl
and supply the lpszAutoConfigUrl
parameter with a URL that contains the credentials. (ie http://user:pass@intranet/
).If you weren't using basic authentication I would suggest looking at fAutoLogonIfChallenged
, but that is of no use to you.
Upvotes: 1