wannaknowmore
Guest
|
Posted:
Tue Dec 06, 2005 1:58 am Post subject:
XMLHTTP with Forms Based Authentication |
|
|
I need to get a list of emails form my inbox that are not read (new
emails).
I am using XMLHTTP and have Forms based Authentication on the exchange
server.
I can get an individual message as well as attachment of a message
using PROPFIND and X-MS-ENUMATTS using HttpWebRequest and cookie
authentication without a problem.
understand that I need to set the cookie header twice but even that
does not work for me; I get 440 Login Timeout.
Code snippet:
strReusableCookies = AuthenticateSecureOWA();
xmlHttp_.open("SEARCH", strSrcURI, false, domain + "\\" + username,
password) ;
xmlHttp_.setRequestHeader ("Cookie", strReusableCookies) ;
xmlHttp_.setRequestHeader ("Cookie", strReusableCookies) ;
xmlHttp_.setRequestHeader("Depth", "1") ;
xmlHttp_.setRequestHeader("Content-type", "text/xml") ;
StringBuilder strXML = new StringBuilder() ;
strXML.Append("<?xml version='1.0' ?>") ;
strXML.Append("<a:searchrequest xmlns:a='DAV:'><a:sql>") ;
strXML.Append("SELECT") ;
strXML.Append(" \"DAV:creationdate\"") ;
strXML.Append(",\"urn:schemas:httpmail:subject\"") ;
strXML.Append(",\"http://schemas.microsoft.com/exchange/permanenturl\"")
;
strXML.Append(",\"urn:schemas:httpmail:hasattachment\"") ;
strXML.Append(",\"urn:schemas:httpmail:read\"") ;
strXML.Append(" FROM scope('shallow traversal of \"" + strSrcURI +
"\"')") ;
strXML.Append(" WHERE \"DAV:ishidden\"=False") ;
strXML.Append(" AND \"DAV:isfolder\"=False") ;
if(!(null == readStatus) && !("".Equals(readStatus)) &&
"true".Equals(readStatus))
strXML.Append(" AND \"urn:schemas:httpmail:read\"=True") ;
else if ("false".Equals(readStatus))
strXML.Append(" AND \"urn:schemas:httpmail:read\"=False") ;
strXML.Append(" ORDER BY \"DAV:creationdate\"") ;
strXML.Append("</a:sql></a:searchrequest>") ;
xmlHttp_.send(strXML.ToString()) ;
string str = xmlHttp_.responseText ;
//Load the read mails into XML document'''
System.Xml.XmlDataDocument xmlDOMParams = new XmlDataDocument() ;
xmlDOMParams.LoadXml(str) ;
The method AuthenticateSecureOWA() returns the cookie string which is
successfully used in other methods to get individual messages.
Any suggestions?
|
|