IServerXMLHTTPRequest & Forms Based Authentication

From: pgt8013 (palakkadan_at_gmail.com)
Date: 03/16/05


Date: 15 Mar 2005 19:32:20 -0800

Friends,

I am running into an issue when i am using IServerXMLHTTPRequest to
connect to an exchange 2003 server with forms based authentication
turned on.

The code works fine when i use IXMLHTTPRequest.

Due to performance reasons & SSL certificate issues i cannot use
IXMLHTTPRequest.

Could one you please help me out here ?

I have attached my sourcecode to the bottom of this post.

Regards
PGT

//

#include "stdafx.h"
#include <stdio.h>
#include<string>
#import <msxml4.dll>
using namespace MSXML2;
using namespace std;

int main(int argc, char* argv[])
{
        CoInitialize(NULL);

   //IXMLHTTPRequestPtr pIXMLHTTPRequest = NULL;
   IServerXMLHTTPRequestPtr pIXMLHTTPRequest = NULL;
   MSXML2::IXMLDOMDocumentPtr pXMLDoc = NULL;
   HRESULT hr;

   try {
      //hr=pIXMLHTTPRequest.CreateInstance(__uuidof(XMLHTTP40));
          hr=pIXMLHTTPRequest.CreateInstance(__uuidof(ServerXMLHTTP40));
      SUCCEEDED(hr) ? 0 : throw hr;
          //string serverUrl =
"https://mail.exchangetrial.com/exchweb/bin/auth/owaauth.dll";
          string serverUrl =
"https://mail.exchangetrial.com/exchweb/bin/auth/owaauth.dll";

          hr=pIXMLHTTPRequest->open("POST",
                  _bstr_t((char *)serverUrl.c_str()),
              false);
          SUCCEEDED(hr) ? 0 : throw hr;
          hr = pIXMLHTTPRequest->setRequestHeader(_bstr_t("Content-type"),
_bstr_t("application/x-www-form-urlencoded"));

          //variant_t x =
pIXMLHTTPRequest->getOption((MSXML2::SERVERXMLHTTP_OPTION)2);
          hr = pIXMLHTTPRequest->setOption((MSXML2::SERVERXMLHTTP_OPTION)2
,13056);
          SUCCEEDED(hr) ? 0 : throw hr;
          string dest =
"destination=https://mail.exchangetrial.com/exchange&username=username@exchangetrial.com&password=password";
          hr=pIXMLHTTPRequest->send(_bstr_t((char *)dest.c_str()));
      SUCCEEDED(hr) ? 0 : throw hr;

          long status = pIXMLHTTPRequest->status;
          printf("Status of the request is %d\n",status);

          _bstr_t t = pIXMLHTTPRequest->getAllResponseHeaders();
          printf("Response headers are %s\n",(char *)t);
          _bstr_t xy =
pIXMLHTTPRequest->getResponseHeader(_bstr_t("sessionid"));

                printf("Response header is %s\n",(char *)xy);

   }
        catch (...) {
          DWORD err = GetLastError();
      printf("error: %d\n",err);
   }

   if (pIXMLHTTPRequest)
      pIXMLHTTPRequest.Release();

   CoUninitialize();

        return 0;
}



Relevant Pages

  • IServerXMLHTTPRequest & Forms Based Authentication
    ... I am running into an issue when i am using IServerXMLHTTPRequest to ... connect to an exchange 2003 server with forms based authentication ... using namespace MSXML2; ...
    (microsoft.public.exchange.development)
  • IServerXMLHTTPRequest authentication problem
    ... I've an authentication problem with IServerXMLHTTPRequest. ... Authentication and I can't use any other type of authentication. ... The file example1.asp try to retrieve some information from example2.asp by ...
    (microsoft.public.inetserver.asp.general)
  • IServerXMLHTTPRequest authentication problem
    ... I've an authentication problem with IServerXMLHTTPRequest. ... Authentication and I can't use any other type of authentication. ... The file example1.asp try to retrieve some information from example2.asp by ...
    (microsoft.public.inetserver.iis.security)
  • IServerXMLHTTPRequest authentication problem
    ... I've an authentication problem with IServerXMLHTTPRequest. ... Authentication and I can't use any other type of authentication. ... The file example1.asp try to retrieve some information from example2.asp by ...
    (microsoft.public.inetserver.misc)

Loading