SAMPLE: Progress Uses IAuthenticate to Bind to Secured Web PageID: Q156905
|
The Progress.exe sample from the ActiveX SDK, Internet Client SDK, and MSDN Online Web Workshop demonstrates how to use a URL moniker to asynchronously bind to data from a remote site on the Internet or an intranet. This Knowledge Base sample extends the original Progress by handling the case where authentication is required to access secured data.
The following file is available for download from the Microsoft Software Library:
Progress.exeFor more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services
Q156904 FIX: Returning User Name and Password from IAuthenticate FailsHandling authentication requests from a URL moniker requires that the URL moniker host implement a bind status callback object which exposes both the IBindStatusCallback interface and the IAuthenticate interface. The sample uses multiple inheritance to expose these interfaces on the same object.
STDMETHODIMP CBindStatusCallback::Authenticate(
HWND __RPC_FAR *phwnd,
LPWSTR __RPC_FAR *pszUsername,
LPWSTR __RPC_FAR *pszPassword)
{
TCHAR pszDlgUser[255];
WCHAR wszDlgUser[255];
TCHAR pszDlgPassword[255];
WCHAR wszDlgPassword[255];
if (!phwnd || !pszUsername || !pszPassword)
{
return E_INVALIDARG;
}
*phwnd = g_hwndDlg;
// If dialog controls have valid user & pass, use that
HWND hWndUser = ::GetDlgItem(g_hwndDlg, IDC_USERNAME);
HWND hWndPassword = ::GetDlgItem(g_hwndDlg, IDC_PASSWORD);
::GetWindowText(hWndUser, pszDlgUser, 1024);
::GetWindowText(hWndPassword, pszDlgPassword, 1024);
if (NULL != pszDlgUser && NULL != pszDlgPassword && '\0' != pszDlgUser[0])
{
MultiByteToWideChar(GetACP(), 0, pszDlgUser, -1, wszDlgUser, 255);
MultiByteToWideChar(GetACP(), 0, pszDlgPassword, -1, wszDlgPassword, 255);
*pszUsername = wszDlgUser;
*pszPassword = wszDlgPassword;
}
else
{
*pszUsername = NULL;
*pszPassword = NULL;
}
return S_OK;
}
Additional query words: URLMON IBSC
Keywords : kbIE300 kbIE400 kbIE401 kbURLMon kbIE500 AXSDKUrlMon
Version : 1.0
Platform : WINDOWS
Issue type :
Last Reviewed: April 29, 1999