Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: 15 Feb 2007 00:40:03 -0800,    group: microsoft.public.exchange.development        back       


Passing credentials with IServerXMLHTTPRequest   
Hi,

Sorry for crossposting this here, but I don't seem to be getting any
response in microsoft.public.xml and I thought maybe one of the gurus
in here can help. In short, I would like to know how to enable
automatic logon when using ServerXMLHttp, so that default credentials
are passed from client to server, instead of having to specify
username/password.


I have an application written in C++ using IServerXMLHTTPRequest to
access items in the exchange store via WebDAV requests. I have been
explicitly entering the username/password in the call to
IServerXMLHTTPRequest.Open (...), but I would like to use windows
authentication instead, i.e. not pass any username/password in that
call and instead use the credentials of the user that is logged in.

When I remove username/password in the call however, I get status 401
returned from the server.

I tested WinHttp instead and I had the same problem, but I solved that
by setting WINHTTP_OPTION_AUTOLOGON_POLICY to
WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW which causes WinHttp to always
delegate default credentials to the server.

But how can I change this setting when using XMLHTTP? I read that
XMLHTTP uses WinHTTP, so it should be possible to connect in the same
way right?

The client and server are on the same domain, but that shouldn't
matter I think. I am quite certain that this problem is in my use of
XMLHTTP since I can get windows authentication working with WinHTTP
and also I can access the exchange store via a browser without having
to provide any credentials.

Relevant code:
_______________________________________________________

HRESULT hr;
CComPtr<IServerXMLHTTPRequest> serverXMLHTTP;

// Create an instance of ServerXMLHTTP Class
hr = serverXMLHTTP.CoCreateInstance(CLSID_ServerXMLHTTP40);
if( FAILED(hr))
        return;

// Initialize the Synchronous HTTP POST request
hr = serverXMLHTTP->open (_bstr_t(_T("SEARCH")), _bstr_t( "http://
server/exchange/uid" ), _variant_t(false) );
if( FAILED(hr))
        return;

strRequest = ....... // set up request to send to server, not really
interesting here

//Setup for transmission
TCHAR szDataLen[32] = {0};
int iDataLen = strRequest.length();     //Get total length of what we
are
sending
itoa(iDataLen, szDataLen, 10);

//Set required http headers
serverXMLHTTP->setRequestHeader(_bstr_t(_T("Content-Type")),
_bstr_t(_T("text/xml")));
serverXMLHTTP->setRequestHeader(_bstr_t(_T("Translate")),
_bstr_t(_T("f")));
serverXMLHTTP->setRequestHeader(_bstr_t(_T("Content-Length")),
_bstr_t( szDataLen ));

// Send the HTTP POST request, with XML document as POST data
hr = serverXMLHTTP->send( _variant_t( strRequest ) );
if( FAILED(hr))
        return;

// Get status code
long status;
serverXMLHTTP->get_status( &status );
_______________________________________________________

As I said, if I explicitly specify username/password, as below,
everything works...

hr = serverXMLHTTP->open (_bstr_t(_T("SEARCH")), _bstr_t( "http://
server/exchange/uid" ), _variant_t(false), _variant_t ( "username" ),
_variant_t ( "password" ) );

Thanks for any help.
 - Jellobiaffra
date: 15 Feb 2007 00:40:03 -0800   author:   Jellobiaffra

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us