1

According to MSDN, WinHttpSetCredentials requires you to specify the exact username and password.

Is there a way to use current user credentials?
Without needing to specify the username and password, that is.

When I send the request, I get a 401 response. (Server is IIS, using NTLM Windows Authentication.)

I tried following MSDN's example here, but the example requires given username and password.

EDIT: Just to make things clearer, I'm currently using code similar to what appears here: winHTTP GET request C++

Community
  • 1
  • 1
Yehuda Shapira
  • 8,460
  • 5
  • 44
  • 66

1 Answers1

2

Someone at work provided an answer:

// Send a request. 
if (hRequest) 
{
    DWORD logonPolicy = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW;
    BOOL fRet = WinHttpSetOption ( hRequest,
        WINHTTP_OPTION_AUTOLOGON_POLICY,
        (LPVOID*) &logonPolicy,
        sizeof(logonPolicy)); 

    bResults = WinHttpSendRequest( hRequest,
        WINHTTP_NO_ADDITIONAL_HEADERS, 
        0, WINHTTP_NO_REQUEST_DATA, 0,  
        0, 0); 
}
Yehuda Shapira
  • 8,460
  • 5
  • 44
  • 66