CWinHttpRequest.SetCredentialsmethod
Sets credentials to be used with an HTTP server, whether it is a proxy server or an originating server.
Syntax
FUNCTION SetCredentials (BYREF wszUserName AS WSTRING, BYREF wszPassword AS WSTRING, BYVAL Flags AS HTTPREQUEST_SETCREDENTIALS_FLAGS) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
wszUserName | A string that specifies the user name for authentication. | |
wszPassword | A string specifies the password for authentication. This parameter is ignored if cbsUserName is NULL or missing. | |
Flags | A value that specifies when CWinHttpRequest uses credentials. Can be one of the below values. |
Return value
Returns S_OK (0) if successful or an error value otherwise.
Description
Sets credentials to be used with an HTTP server, whether it is a proxy server or an originating server.
Remarks
This method returns an error value if a call to Open has not completed successfully. It is assumed that some measure of interaction with a proxy server or origin server must occur before users can set credentials for the session. Moreover, until users know which authentication scheme(s) are supported, they cannot format the credentials.
To authenticate with both the server and the proxy, the application must call SetCredentials twice; first with the Flags parameter set to HTTPREQUEST_SETCREDENTIALS_FOR_SERVER, and second, with the Flags parameter set to HTTPREQUEST_SETCREDENTIALS_FOR_PROXY.
Reference
- Defined in AfxNova/CWinHttpRequest.inc:393
- Documented in COM/CWinHttpRequest Class.md
- Topic: CWinHttpRequest Class