WebDAV - 440 Login Timeout

Skip to first unread message

Narayanan Sankaranarayanan

Feb 12, 2006, 10:07:38 PM2/12/06

I am trying to access my company's corporate exchange server using WebDAV.

The objective is to send emails using WebDAV.

The server is setup with Form Based Authentication (FBA). I downloaded this
code from the internet.

For some reason I keep getting this 440 Login Timeout error.

Any help in this regard would be greatly appreciated. If you have a working
sample it would be better.



Here is my code
<script language="JavaScript" type="text/javascript">
function getMessages()
var strCookies;
var strRequest;
var objXmlResult;

strCookies = doFBALogin( "https://mail.exchangeserver.com/public",
"mail.exchangeserver.com", "Domain\UserID", "MyPassword" );

strRequest = "<D:searchrequest xmlns:D = \"DAV:\" ><D:sql>SELECT
\"DAV:displayname\" FROM \"https://mail.exchangeserver.com/public\" WHERE
\"DAV:ishidden\" = false</D:sql></D:searchrequest>";

objXmlResult = Search( "https://mail.exchangeserver.com/public",
strRequest, strCookies );

//Do something with the XML object
catch( e )
// Handle the error!
alert( e );

return( false );

function Search( strUrl, strQuery, strCookies )
// Send the request to the server
var xmlHTTP = new ActiveXObject( "Microsoft.xmlhttp" );
var i;

xmlHTTP.open( "SEARCH", strUrl, false );
xmlHTTP.setRequestHeader( "Content-type:", "text/xml" );

// Add the cookies to the request. According to Microsoft article Q234486,
the cookie has to be set two times.
xmlHTTP.setRequestHeader( "Cookies", "Necessary according to Q234486" );
xmlHTTP.setRequestHeader( "Cookies", strCookies );
xmlHTTP.send( strQuery );

return( xmlHTTP.responseXML );

function doFBALogin( strDestination, strServer, strUsername, strPassword )
var xmlHTTP = new ActiveXObject( "Microsoft.XMLHttp" );
var strUrl;
var strContent;
var arrHeader;
var strCookies;
var intCookies;
var i;

// Prepare the URL for FBA login
strUrl = "https://" + strServer + "/exchweb/bin/auth/owaauth.dll";

xmlHTTP.open( "POST", strUrl, false );

xmlHTTP.setRequestHeader( "Content-type:",
"application/x-www-form-urlencoded" );

// Generate the body for FBA login
strContent = "destination=" + strDestination + "&username=" + strUsername +
"&password=" + strPassword;
xmlHTTP.send( strContent );

alert( xmlHTTP.responseText );

// Get all response headers
arrHeader = xmlHTTP.getAllResponseHeaders().split( "\n" );
strCookies = "";

intCookies = 0;

// Iterate through the collection of returned headers
for( i = 0; i < arrHeader.length; i++ )
// If the entry is a cookies, extract the name/value
if( arrHeader[i].indexOf( "Set-Cookie" ) != -1 )
strCookies += arrHeader[i].substr( 12 ) + "; ";

// Check if two cookies have been returned. Otherwise throw an exception
if( intCookies < 2 )
throw "Could not log in to OWA!";

return( strCookies );
<font face='Verdana' size='2'>
Mailbox name:<br>
<input type='text' name='mailbox' value="MyUserID"><br>
<input type='button' name='getMessages' value=' GO '
onClick="return( getMessages() );"><br>


Glen Scales [MVP]

Feb 14, 2006, 5:40:55 PM2/14/06
This section of code looks a little suss

xmlHTTP.setRequestHeader( "Cookies", "Necessary according to Q234486" );
xmlHTTP.setRequestHeader( "Cookies", strCookies );

I would say that line should have just repeated

xmlHTTP.setRequestHeader( "Cookies", strCookies );
xmlHTTP.setRequestHeader( "Cookies", strCookies );


"Narayanan Sankaranarayanan" <s_nar...@hotmail.com> wrote in message

Henning Krause [MVP]

Feb 14, 2006, 6:11:06 PM2/14/06
Hi Glen,

the KB article states that the first call to setRequestHeader is ignored.
The documentation for setRequestHeader states that a repeated call to
setRequestHeader will overwrite any previous values. In my tests that
statement did not caused the login function to fail.

Narayanan, did you check the cookies that came back from the server? There
should be at least two cookies.


"Glen Scales [MVP]" <gsc...@outlookexchange.com> wrote in message

Reply all
Reply to author
0 new messages