WebDAV - 440 Login Timeout
Hi,
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.
Thanks
Narayanan
Here is my code
=======================================================================================
<html>
<head>
<script language="JavaScript" type="text/javascript">
function getMessages()
{
var strCookies;
var strRequest;
var objXmlResult;
try
{
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 ) "; ";
intCookies;
}
}
// Check if two cookies have been returned. Otherwise throw an exception
if( intCookies < 2 )
{
throw "Could not log in to OWA!";
}
return( strCookies );
}
</script>
</head>
<body>
<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>
</body>
</html>
=======================================================================================
date: Sun, 12 Feb 2006 19:06:57 -0800
author: Narayanan Sankaranarayanan