ServerXMLHttpRequest and forms based authentication
Hi,
I am developing a WinNT service on XP SP2(using unmanaged C++) that
communicates with an exchange frontend server using WebDAV.
I am trying to handle forms based authentication based on Henning
Krause's work
http://www.infinitec.de/articles/exchange/webdavwithfba.aspx
I changed the code to use ServerXMLHttpRequest instead of
XMLHttpRequest and I get a 403.
Enclosed code below.
I am at loss to understand why using XMLHttp works and ServerXMLHTTP
fails.
Has anyone come across this before ?
-Alexei
//------------Code-------------------------------------------
CComPtr<MSXML::IXMLHTTPRequest> pHTTPReq;
hr = pHTTPReq.CoCreateInstance(MSXML::CLSID_ServerXMLHT TP);
hr = pHTTPReq->open(_bstr_t(DAV_REQUEST_POST),
_bstr_t(strURL),VARIANT_FALSE);
hr = pHTTPReq->setRequestHeader(_bstr_t(_T("User-Agent")),
_bstr_t(_T("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;
..NET CLR 1.1.4322)")));
hr = pHTTPReq->setRequestHeader(_bstr_t(_T("encoding")),
_bstr_t(_T("UTF-8")));
hr = pHTTPReq->setRequestHeader(_bstr_t(_T("Content-type")),
_bstr_t(_T("application/x-www-form-urlencoded")));
wstringstream streamBody;
streamBody << _T("destination=")
<< (LPCTSTR)m_pApiAttrs->m_strNetProtocol
<< _T("%3A%2F%2F")
<< (LPCTSTR)m_pApiAttrs->m_strExchangeServerName
<< _T(":")
<< (LPCTSTR)m_pApiAttrs->m_strNetPort
<< _T("%2Fexchange%2F")
<< (LPCTSTR)m_pApiAttrs->m_strXCHGUserName
<< _T("%2F&username=")
<< (LPCTSTR)m_pApiAttrs->m_strXCHGDomainName
<< _T("%5C")
<< (LPCTSTR)m_pApiAttrs->m_strXCHGUserName
<< _T("&password=")
<< (LPCTSTR)m_pApiAttrs->m_strXCHGPassword
<< _T("&SubmitCreds=Log+On&forcedownlevel=0&trusted=0 ")
<< ends;
hr = pHTTPReq->send(_bstr_t(streamBody.str().c_str()));
CString strReplyXML = (TCHAR*)pHTTPReq->responseText;
|