Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

696 lines
20 KiB

  1. #include <wininetp.h>
  2. #include <urlmon.h>
  3. #include <splugin.hxx>
  4. #include "htuu.h"
  5. /*---------------------------------------------------------------------------
  6. PASSPORT_CTX
  7. ---------------------------------------------------------------------------*/
  8. /*---------------------------------------------------------------------------
  9. Constructor
  10. ---------------------------------------------------------------------------*/
  11. PASSPORT_CTX::PASSPORT_CTX(HTTP_REQUEST_HANDLE_OBJECT *pRequest, BOOL fIsProxy,
  12. SPMData* pSPM, AUTH_CREDS* pCreds)
  13. : AUTHCTX(pSPM, pCreds)
  14. {
  15. _fIsProxy = fIsProxy;
  16. _pRequest = pRequest;
  17. m_hLogon = NULL;
  18. m_pNewThreadInfo = NULL;
  19. m_pwszPartnerInfo = NULL;
  20. m_lpszRetUrl = NULL;
  21. m_wRealm[0] = '\0';
  22. m_FromPP[0] = '\0';
  23. ::MultiByteToWideChar(CP_ACP, 0, _pRequest->GetServerName(), -1, m_wTarget, MAX_AUTH_TARGET_LEN);
  24. }
  25. BOOL PASSPORT_CTX::Init(void)
  26. {
  27. m_pNewThreadInfo = ::InternetCreateThreadInfo(FALSE);
  28. if (m_pNewThreadInfo == NULL)
  29. {
  30. return FALSE;
  31. }
  32. LPINTERNET_THREAD_INFO pCurrentThreadInfo = ::InternetGetThreadInfo();
  33. m_pNewThreadInfo->ThreadId = ::GetCurrentThreadId();
  34. ::InternetSetThreadInfo(m_pNewThreadInfo);
  35. m_pInternet = GetRootHandle (_pRequest);
  36. if (!m_pInternet->GetPPContext())
  37. {
  38. PP_CONTEXT hPP = ::PP_InitContext(L"WinHttp5.Dll", NULL);
  39. m_pInternet->SetPPContext(hPP);
  40. hPP = NULL;
  41. }
  42. ::InternetSetThreadInfo(pCurrentThreadInfo);
  43. if (!m_pInternet->GetPPContext())
  44. {
  45. return FALSE;
  46. }
  47. return TRUE;
  48. }
  49. /*---------------------------------------------------------------------------
  50. Destructor
  51. ---------------------------------------------------------------------------*/
  52. PASSPORT_CTX::~PASSPORT_CTX()
  53. {
  54. LPINTERNET_THREAD_INFO pCurrentThreadInfo = ::InternetGetThreadInfo();
  55. m_pNewThreadInfo->ThreadId = ::GetCurrentThreadId();
  56. ::InternetSetThreadInfo(m_pNewThreadInfo);
  57. if (m_hLogon)
  58. {
  59. ::PP_FreeLogonContext(m_hLogon);
  60. m_hLogon = NULL;
  61. }
  62. ::InternetSetThreadInfo(pCurrentThreadInfo);
  63. if (m_pNewThreadInfo)
  64. {
  65. ::InternetFreeThreadInfo(m_pNewThreadInfo);
  66. }
  67. if (m_pwszPartnerInfo)
  68. {
  69. delete [] m_pwszPartnerInfo;
  70. }
  71. if (m_lpszRetUrl)
  72. {
  73. delete [] m_lpszRetUrl;
  74. }
  75. }
  76. CHAR g_szPassportDAHost[256];
  77. BOOL PASSPORT_CTX::CallbackRegistered(void)
  78. {
  79. LPINTERNET_THREAD_INFO lpThreadInfo = InternetGetThreadInfo();
  80. if (lpThreadInfo)
  81. {
  82. WINHTTP_STATUS_CALLBACK appCallback =
  83. ((INTERNET_HANDLE_BASE *)lpThreadInfo->hObjectMapped)->GetStatusCallback();
  84. if (appCallback != NULL)
  85. {
  86. return TRUE;
  87. }
  88. }
  89. return FALSE;
  90. }
  91. DWORD PASSPORT_CTX::HandleSuccessfulLogon(
  92. LPWSTR pwszFromPP,
  93. PDWORD pdwFromPP,
  94. BOOL fPreAuth
  95. )
  96. {
  97. // biaow-todo: I am betting the RU DWORD UrlLength = 1024;
  98. LPWSTR pwszUrl = (LPWSTR) ALLOCATE_FIXED_MEMORY(1024 * sizeof(WCHAR));
  99. DWORD dwwUrlLength = 1024;// won't be too long, but I could be wrong
  100. LPSTR pszUrl = (LPSTR) ALLOCATE_FIXED_MEMORY(dwwUrlLength * sizeof(CHAR));
  101. BOOL fRetrySameUrl;
  102. DWORD dwRet = ERROR_SUCCESS;
  103. if (pwszUrl == NULL || pszUrl == NULL)
  104. {
  105. dwRet = ERROR_NOT_ENOUGH_MEMORY;
  106. goto exit;
  107. }
  108. if (::PP_GetAuthorizationInfo(m_hLogon,
  109. pwszFromPP,
  110. pdwFromPP,
  111. &fRetrySameUrl,
  112. pwszUrl,
  113. &dwwUrlLength
  114. ) == FALSE)
  115. {
  116. INET_ASSERT(TRUE); // this shouldn't happen
  117. dwRet = ERROR_WINHTTP_LOGIN_FAILURE;
  118. goto exit;
  119. }
  120. // save the DA Host name for Logout security check
  121. WCHAR wszDAHost[256];
  122. DWORD dwHostLen = ARRAY_ELEMENTS(wszDAHost);
  123. if (::PP_GetLogonHost(m_hLogon,
  124. wszDAHost, &dwHostLen) == TRUE)
  125. {
  126. ::WideCharToMultiByte(CP_ACP, 0, wszDAHost, -1, g_szPassportDAHost, 256, NULL, NULL);
  127. }
  128. if (!fRetrySameUrl)
  129. {
  130. if (_pRequest->GetMethodType() == HTTP_METHOD_TYPE_GET)
  131. {
  132. // DA wanted us to GET to a new Url
  133. ::WideCharToMultiByte(CP_ACP, 0, pwszUrl, -1, pszUrl, 1024, NULL, NULL);
  134. }
  135. else
  136. {
  137. fRetrySameUrl = TRUE; // *** WinHttp currently supports retry custom verb to same URL only ***
  138. }
  139. }
  140. if (fPreAuth)
  141. {
  142. // We are sending, in the context of AuthOnRequest.
  143. if (fRetrySameUrl)
  144. {
  145. // DA told us to keep Verb & Url, so there is nothing more needs to be done
  146. goto exit;
  147. }
  148. // Regardless whether we are asked to handle redirect, we'll need to fake
  149. // that a 302 just came in.
  150. // biaow-todo: this is causing problem for QueryHeaders(StatusCode). I don't know why yet...
  151. /*
  152. _pRequest->AddInternalResponseHeader(HTTP_QUERY_STATUS_TEXT, // use non-standard index, since we never query this normally
  153. "HTTP/1.0 302 Object Moved",
  154. strlen("HTTP/1.0 302 Object Moved")
  155. );
  156. _pRequest->AddInternalResponseHeader(HTTP_QUERY_LOCATION,
  157. pszUrl,
  158. strlen(pszUrl));
  159. */
  160. if (_pRequest->GetOpenFlags() & INTERNET_FLAG_NO_AUTO_REDIRECT)
  161. {
  162. if (!CallbackRegistered())
  163. {
  164. _pRequest->SetPPAbort(TRUE);
  165. dwRet = ERROR_WINHTTP_LOGIN_FAILURE;
  166. goto exit;
  167. }
  168. }
  169. ::InternetIndicateStatusString(WINHTTP_CALLBACK_STATUS_REDIRECT, pszUrl);
  170. }
  171. else
  172. {
  173. // We are receiving a 302, in the context of AuthOnResponse.
  174. // Here we need to re-play the request to lpszRetUrl. One way to
  175. // achieve this is returning ERROR_INTERNET_FORCE_RETRY. But before
  176. // that, we'll need to remember the lpszRetUrl.
  177. // *NOTE* This is in effective an 401. To prevent the send path from
  178. // following the 302 Location: header, caller must set the status code
  179. // to 401.
  180. if (!fRetrySameUrl)
  181. {
  182. if (_pRequest->GetOpenFlags() & INTERNET_FLAG_NO_AUTO_REDIRECT)
  183. {
  184. if (!CallbackRegistered())
  185. {
  186. dwRet = ERROR_WINHTTP_LOGIN_FAILURE;
  187. goto exit;
  188. }
  189. ::InternetIndicateStatusString(WINHTTP_CALLBACK_STATUS_REDIRECT, pszUrl);
  190. }
  191. }
  192. dwRet = ERROR_WINHTTP_RESEND_REQUEST;
  193. }
  194. PCSTR lpszRetUrl = NULL;
  195. if (fRetrySameUrl)
  196. {
  197. lpszRetUrl = _pRequest->GetURL();
  198. }
  199. else
  200. {
  201. lpszRetUrl = pszUrl;
  202. }
  203. if (m_lpszRetUrl)
  204. {
  205. delete [] m_lpszRetUrl;
  206. }
  207. m_lpszRetUrl = new CHAR[strlen(lpszRetUrl) + 1];
  208. if (m_lpszRetUrl)
  209. {
  210. strcpy(m_lpszRetUrl, lpszRetUrl);
  211. }
  212. exit:
  213. if (pwszUrl)
  214. {
  215. FREE_MEMORY(pwszUrl);
  216. }
  217. if (pszUrl)
  218. {
  219. FREE_MEMORY(pszUrl);
  220. }
  221. return dwRet;
  222. }
  223. /*---------------------------------------------------------------------------
  224. PreAuthUser
  225. ---------------------------------------------------------------------------*/
  226. DWORD PASSPORT_CTX::PreAuthUser(IN LPSTR pBuf, IN OUT LPDWORD pcbBuf)
  227. {
  228. DEBUG_ENTER ((
  229. DBG_HTTP,
  230. Dword,
  231. "PASSPORT_CTX::PreAuthUser",
  232. "this=%#x pBuf=%#x pcbBuf=%#x {%d}",
  233. this,
  234. pBuf,
  235. pcbBuf,
  236. *pcbBuf
  237. ));
  238. DWORD dwError = ERROR_SUCCESS;
  239. LPWSTR pwszFromPP = NULL;
  240. LPWSTR pwszUser = NULL;
  241. LPWSTR pwszPass = NULL;
  242. // Prefix the header value with the auth type.
  243. const static BYTE szPassport[] = "Passport1.4 ";
  244. #define PASSPORT_LEN sizeof(szPassport)-1
  245. if (m_FromPP[0] == '\0')
  246. {
  247. DWORD dwFromPPLen = 2048;
  248. pwszFromPP = (LPWSTR) ALLOCATE_FIXED_MEMORY(dwFromPPLen * sizeof(WCHAR));
  249. if (pwszFromPP == NULL)
  250. {
  251. dwError = ERROR_NOT_ENOUGH_MEMORY;
  252. goto exit;
  253. }
  254. LPINTERNET_THREAD_INFO pCurrentThreadInfo = ::InternetGetThreadInfo();
  255. m_pNewThreadInfo->ThreadId = ::GetCurrentThreadId();
  256. ::InternetSetThreadInfo(m_pNewThreadInfo);
  257. // if an app already specified creds, use them and do a pre-authentication.
  258. if (_pCreds->lpszUser && _pCreds->lpszPass)
  259. {
  260. pwszUser = (LPWSTR) ALLOCATE_FIXED_MEMORY((strlen(_pCreds->lpszUser) + 1) * sizeof(WCHAR));
  261. pwszPass = (LPWSTR) ALLOCATE_FIXED_MEMORY((strlen(_pCreds->lpszPass) + 1) * sizeof(WCHAR));
  262. if (pwszUser == NULL || pwszPass == NULL)
  263. {
  264. ::InternetSetThreadInfo(pCurrentThreadInfo);
  265. dwError = ERROR_NOT_ENOUGH_MEMORY;
  266. goto cleanup;
  267. }
  268. ::MultiByteToWideChar(CP_ACP, 0, _pCreds->lpszUser, -1, pwszUser, strlen(_pCreds->lpszUser) + 1);
  269. ::MultiByteToWideChar(CP_ACP, 0, _pCreds->lpszPass, -1, pwszPass, strlen(_pCreds->lpszPass) + 1);
  270. ::PP_SetCredentials(m_hLogon, NULL, NULL, pwszUser, pwszPass);
  271. }
  272. // we could do a PP_SetCredentials(...null,null) here. But I don't think we need to.
  273. DWORD dwLogonStatus = ::PP_Logon(m_hLogon,
  274. 0,
  275. NULL,
  276. 0);
  277. ::InternetSetThreadInfo(pCurrentThreadInfo);
  278. if (dwLogonStatus != PP_LOGON_SUCCESS)
  279. {
  280. dwError = ERROR_WINHTTP_LOGIN_FAILURE;
  281. goto cleanup;
  282. }
  283. dwError = HandleSuccessfulLogon(pwszFromPP, &dwFromPPLen, TRUE);
  284. if (dwError == ERROR_WINHTTP_LOGIN_FAILURE)
  285. {
  286. goto cleanup;
  287. }
  288. ::WideCharToMultiByte(CP_ACP, 0, pwszFromPP, -1, m_FromPP, 2048, NULL, NULL);
  289. }
  290. // check to see if we need to update url
  291. if (m_lpszRetUrl)
  292. {
  293. _pRequest->ModifyRequest(_pRequest->GetMethodType(),
  294. m_lpszRetUrl,
  295. strlen(m_lpszRetUrl),
  296. NULL,
  297. 0);
  298. delete [] m_lpszRetUrl;
  299. m_lpszRetUrl = NULL;
  300. }
  301. // Ticket and profile is already present
  302. // put in the header
  303. memcpy (pBuf, szPassport, PASSPORT_LEN);
  304. pBuf += PASSPORT_LEN;
  305. // append the ticket
  306. strcpy(pBuf, m_FromPP);
  307. *pcbBuf = PASSPORT_LEN + strlen(m_FromPP);
  308. cleanup:
  309. if (pwszFromPP)
  310. FREE_MEMORY(pwszFromPP);
  311. if (pwszUser)
  312. FREE_MEMORY(pwszUser);
  313. if (pwszPass)
  314. FREE_MEMORY(pwszPass);
  315. exit:
  316. DEBUG_LEAVE(dwError);
  317. return dwError;
  318. }
  319. /*---------------------------------------------------------------------------
  320. UpdateFromHeaders
  321. ---------------------------------------------------------------------------*/
  322. DWORD PASSPORT_CTX::UpdateFromHeaders(HTTP_REQUEST_HANDLE_OBJECT *pRequest, BOOL fIsProxy)
  323. {
  324. DEBUG_ENTER ((
  325. DBG_HTTP,
  326. Dword,
  327. "PASSPORT_CTX::UpdateFromHeaders",
  328. "this=%#x request=%#x isproxy=%B",
  329. this,
  330. pRequest,
  331. fIsProxy
  332. ));
  333. DWORD dwAuthIdx, cbChallenge, dwError;
  334. LPSTR szChallenge = NULL;
  335. LPINTERNET_THREAD_INFO pCurrentThreadInfo = NULL;
  336. LPINTERNET_THREAD_INFO pNewThreadInfo = NULL;
  337. // Get the associated header.
  338. if ((dwError = FindHdrIdxFromScheme(&dwAuthIdx)) != ERROR_SUCCESS)
  339. goto exit;
  340. // Get the complete auth header.
  341. dwError = GetAuthHeaderData(pRequest, fIsProxy, NULL,
  342. &szChallenge, &cbChallenge, ALLOCATE_BUFFER, dwAuthIdx);
  343. if (dwError != ERROR_SUCCESS)
  344. {
  345. szChallenge = NULL;
  346. goto exit;
  347. }
  348. if (!_pCreds)
  349. {
  350. _pCreds = CreateCreds(pRequest, fIsProxy, _pSPMData, NULL);
  351. if (!_pCreds)
  352. {
  353. dwError = ERROR_NOT_ENOUGH_MEMORY;
  354. goto exit;
  355. }
  356. }
  357. if (m_pwszPartnerInfo)
  358. {
  359. delete [] m_pwszPartnerInfo;
  360. }
  361. {
  362. HTTP_METHOD_TYPE tOrgMethod = _pRequest->GetMethodType();
  363. PCSTR pszOrgVerb;
  364. ::MapHttpMethodType(tOrgMethod, &pszOrgVerb);
  365. PCSTR pszOrgUrl = _pRequest->GetURL();
  366. const LPWSTR pwszOrgVerbAttr = L",OrgVerb=";
  367. const LPWSTR pwszOrgUrlAttr = L",OrgUrl=";
  368. DWORD dwPartnerInfoLength = cbChallenge
  369. +::wcslen(pwszOrgVerbAttr)
  370. +::strlen(pszOrgVerb)
  371. +::wcslen(pwszOrgUrlAttr)
  372. +::strlen(pszOrgUrl)
  373. + 1; // NULL terminator
  374. DWORD dwSize = 0;
  375. PWSTR pwszPartnerInfo = NULL;
  376. m_pwszPartnerInfo = new WCHAR[dwPartnerInfoLength];
  377. if (m_pwszPartnerInfo == NULL)
  378. {
  379. dwError = ERROR_NOT_ENOUGH_MEMORY;
  380. goto exit;
  381. }
  382. pwszPartnerInfo = m_pwszPartnerInfo;
  383. dwSize = ::MultiByteToWideChar(CP_ACP, 0, szChallenge, -1, pwszPartnerInfo, dwPartnerInfoLength) - 1;
  384. ::wcscat(pwszPartnerInfo, pwszOrgVerbAttr);
  385. pwszPartnerInfo += (dwSize + wcslen(pwszOrgVerbAttr));
  386. dwPartnerInfoLength -= (dwSize + wcslen(pwszOrgVerbAttr));
  387. dwSize = ::MultiByteToWideChar(CP_ACP, 0, pszOrgVerb, -1, pwszPartnerInfo, dwPartnerInfoLength) - 1;
  388. ::wcscat(pwszPartnerInfo, pwszOrgUrlAttr);
  389. pwszPartnerInfo += (dwSize + wcslen(pwszOrgUrlAttr));
  390. dwPartnerInfoLength -= (dwSize + wcslen(pwszOrgUrlAttr));
  391. dwSize = ::MultiByteToWideChar(CP_ACP, 0, pszOrgUrl, -1, pwszPartnerInfo, dwPartnerInfoLength) - 1;
  392. dwError = ERROR_SUCCESS;
  393. }
  394. exit:
  395. if (szChallenge)
  396. delete []szChallenge;
  397. DEBUG_LEAVE(dwError);
  398. return dwError;
  399. }
  400. BOOL PASSPORT_CTX::InitLogonContext(void)
  401. {
  402. // set up the thread context before calling the Passport auth library
  403. LPINTERNET_THREAD_INFO pCurrentThreadInfo = ::InternetGetThreadInfo();
  404. m_pNewThreadInfo->ThreadId = ::GetCurrentThreadId();
  405. ::InternetSetThreadInfo(m_pNewThreadInfo);
  406. if (!m_hLogon)
  407. {
  408. INET_ASSERT(m_pInternet->GetPPContext()); // must have been initialized in the Init() call
  409. m_hLogon = ::PP_InitLogonContext(
  410. m_pInternet->GetPPContext(),
  411. m_pwszPartnerInfo,
  412. (_pRequest->GetOpenFlags() & INTERNET_FLAG_NO_COOKIES)
  413. );
  414. }
  415. // restore the WinHttp thread context
  416. ::InternetSetThreadInfo(pCurrentThreadInfo);
  417. return m_hLogon != NULL;
  418. }
  419. /*---------------------------------------------------------------------------
  420. PostAuthUser
  421. ---------------------------------------------------------------------------*/
  422. DWORD PASSPORT_CTX::PostAuthUser()
  423. {
  424. DEBUG_ENTER ((
  425. DBG_HTTP,
  426. Dword,
  427. "PASSPORT_CTX::PostAuthUser",
  428. "this=%#x",
  429. this
  430. ));
  431. LPWSTR pwszUser = NULL;
  432. LPWSTR pwszPass = NULL;
  433. DWORD dwRet = ERROR_SUCCESS;
  434. if (InitLogonContext() == FALSE)
  435. {
  436. dwRet = ERROR_WINHTTP_LOGIN_FAILURE;
  437. goto Cleanup;
  438. }
  439. // if an app already specified creds, use them and do a pre-authentication.
  440. if (_pCreds->lpszUser && _pCreds->lpszPass)
  441. {
  442. pwszUser = (LPWSTR) ALLOCATE_FIXED_MEMORY(1024*sizeof(WCHAR));
  443. pwszPass = (LPWSTR) ALLOCATE_FIXED_MEMORY(1024*sizeof(WCHAR));
  444. if (pwszUser && pwszPass)
  445. {
  446. ::MultiByteToWideChar(CP_ACP, 0, _pCreds->lpszUser, -1, pwszUser, 1024);
  447. ::MultiByteToWideChar(CP_ACP, 0, _pCreds->lpszPass, -1, pwszPass, 1024);
  448. ::PP_SetCredentials(m_hLogon, NULL, NULL, pwszUser, pwszPass);
  449. }
  450. else
  451. {
  452. dwRet = ERROR_NOT_ENOUGH_MEMORY;
  453. goto Cleanup;
  454. }
  455. }
  456. // Ok, Let's give it a try
  457. LPINTERNET_THREAD_INFO pCurrentThreadInfo = ::InternetGetThreadInfo();
  458. m_pNewThreadInfo->ThreadId = ::GetCurrentThreadId();
  459. ::InternetSetThreadInfo(m_pNewThreadInfo);
  460. DWORD dwLogonStatus = ::PP_Logon(m_hLogon,
  461. 0,
  462. NULL,
  463. 0);
  464. // restore the WinHttp thread context
  465. ::InternetSetThreadInfo(pCurrentThreadInfo);
  466. if (dwLogonStatus == PP_LOGON_FAILED)
  467. {
  468. // App/User supplied wrong creds, sorry.
  469. dwRet = ERROR_WINHTTP_LOGIN_FAILURE;
  470. }
  471. else if (dwLogonStatus == PP_LOGON_REQUIRED)
  472. {
  473. // no creds specified, we are required to sign on.
  474. // change from 302 to 401
  475. _pRequest->ReplaceResponseHeader(HTTP_QUERY_STATUS_CODE,
  476. "401", strlen("401"),
  477. 0, HTTP_ADDREQ_FLAG_REPLACE);
  478. // biaow-todo: 1) nice to replace the status text as well; weird to have "HTTP/1.1 401 object moved"
  479. // for example 2) remove the Location: header
  480. if (RetryLogon() == TRUE)
  481. {
  482. dwRet = ERROR_WINHTTP_RESEND_REQUEST;
  483. }
  484. else
  485. {
  486. dwRet = ERROR_WINHTTP_INCORRECT_PASSWORD;
  487. }
  488. }
  489. else if (dwLogonStatus == PP_LOGON_SUCCESS)
  490. {
  491. // wow! we got in!!!
  492. LPWSTR pwszFromPP = (LPWSTR) ALLOCATE_FIXED_MEMORY(2048*sizeof(WCHAR));
  493. DWORD dwFromPPLen = 2048;
  494. if (pwszFromPP)
  495. {
  496. dwRet = HandleSuccessfulLogon(pwszFromPP, &dwFromPPLen, FALSE);
  497. if (dwRet != ERROR_WINHTTP_LOGIN_FAILURE)
  498. {
  499. ::WideCharToMultiByte(CP_ACP, 0, pwszFromPP, -1, m_FromPP, 2048, NULL, NULL);
  500. }
  501. FREE_MEMORY(pwszFromPP);
  502. }
  503. else
  504. {
  505. dwRet = ERROR_NOT_ENOUGH_MEMORY;
  506. }
  507. }
  508. else
  509. {
  510. dwRet = ERROR_WINHTTP_LOGIN_FAILURE;
  511. }
  512. Cleanup:
  513. _pRequest->SetStatusCode(401); // this is needed to prevent send code from tracing Location: header
  514. if (pwszUser)
  515. FREE_MEMORY(pwszUser);
  516. if (pwszPass)
  517. FREE_MEMORY(pwszPass);
  518. DEBUG_LEAVE(dwRet);
  519. return dwRet;
  520. }
  521. /*---------------------------------------------------------------------------
  522. PASSPORT_CTX::PromptForCreds
  523. ---------------------------------------------------------------------------*/
  524. BOOL PASSPORT_CTX::RetryLogon(void)
  525. {
  526. DEBUG_ENTER ((
  527. DBG_HTTP,
  528. Dword,
  529. "PASSPORT_CTX::PromptForCreds",
  530. "this=%#x",
  531. this
  532. ));
  533. // WCHAR wUser[1024] = {0}; LPWSTR pwszUser = NULL;
  534. // WCHAR wPass[1024] = {0}; LPWSTR pwszPass = NULL;
  535. BOOL fRetry = FALSE;
  536. INET_ASSERT(m_hLogon != 0);
  537. BOOL fPrompt = FALSE;
  538. WCHAR wRealm[MAX_AUTH_REALM_LEN];
  539. ::PP_GetChallengeInfo(m_hLogon,
  540. NULL, &fPrompt,
  541. NULL, 0,
  542. wRealm, MAX_AUTH_REALM_LEN);
  543. if (fPrompt)
  544. {
  545. goto exit;
  546. }
  547. /*
  548. if (_pCreds->GetUser() && _pCreds->GetPass())
  549. {
  550. ::MultiByteToWideChar(CP_ACP, 0, _pCreds->GetUser(), -1, wUser, 1024);
  551. ::MultiByteToWideChar(CP_ACP, 0, _pCreds->GetPass(), -1, wPass, 1024);
  552. pwszUser = wUser;
  553. pwszPass = wPass;
  554. }
  555. */
  556. if (::PP_SetCredentials(m_hLogon, wRealm, m_wTarget, NULL, NULL) == TRUE)
  557. {
  558. fRetry = TRUE;
  559. goto exit;
  560. }
  561. exit:
  562. DEBUG_LEAVE((DWORD) fRetry);
  563. return (DWORD) fRetry;
  564. }