webdav error 409 in remote server

webdav error 409 in remote server

Post by Jose Manue » Fri, 02 Mar 2007 19:34:26


ello,



I am trying to make work the webdav example from:



http://msdn2.microsoft.com/en-us/library/ms875692.aspx

http://msdn2.microsoft.com/en-us/library/ms877306.aspx



(I have form authentication in my Exchange server)



I get error in remote Server (409) Conflict



I can see in the exchange session init that the program connects but I do
not know why the error in the final "PROPPATCHRequest.GetResponse()"



Thank you in advance.



This is the code:





Imports System

Imports System.Net

Imports System.IO

Imports System.Xml

Imports System.Text.RegularExpressions

Imports System.Net.HttpWebRequest



Module Module1



'Implementation of the Authentication to the Exchange Server 2003 server
that is enabled with forms-based authentication

Private Function AuthenticateSecureOWA(ByVal strServerName As String,
ByVal strDomain As String, ByVal strUserName As String, ByVal strPassword As
String) As String

' Code to call the Authentication:

Dim CookieJar As CookieContainer

Dim strCookies As String



Dim AuthURL As System.Uri



Try

' Construct our destination URI.

AuthURL = New System.Uri("https://" + strServerName +
"/exchweb/bin/auth/owaauth.dll")

Catch ex As Exception

MsgBox("Error occurred while you are creating the URI for OWA
authentication!" + vbCrLf + vbCrLf + ex.Message)

Return "Error"

End Try



Dim WebReq As HttpWebRequest

CookieJar = New CookieContainer



' Create our request object for the constructed URI.

WebReq = CType(WebRequest.Create(AuthURL), HttpWebRequest)

WebReq.CookieContainer = CookieJar



' Create our post data string that is required by OWA (owaauth.dll).

Dim strPostFields As String = "destination=https%3A%2F%2F" &
strServerName & "%2Fexchange%2F" + strUserName + "%2F&username=" + strDomain
+ "%5C" + strUserName + "&password=" + strPassword +
"&SubmitCreds=Log+On&forcedownlevel=0&trusted=0"



WebReq.KeepAlive = True

WebReq.AllowAutoRedirect = False

WebReq.Method = "POST"



' Store the post data into a byte array.

Dim PostData() As Byte =
System.Text.Encoding.ASCII.GetBytes(strPostFields)



' Set the content length.

WebReq.ContentLength = PostData.Length



Dim tmpStream As Stream



Try

' Create a request stream. Write the post data to the stream.

tmpStream = WebReq.GetRequestStream()

tmpStream.Write(PostData, 0, PostData.Length)

tmpStream.Close()

Catch ex As Exception

MsgBox("Error occurred while trying OWA authentication!" + vbCrLf +
vbCrLf + ex.Message)

Return "Error"

End Try



' Get the response from the request.

Dim WebResp As HttpWebResponse = WebReq.GetResponse()



' Create a stream to capture the response data

Dim tmpStreamRead As New StreamReader(WebResp.GetResponseStream())



' Write returned data to a string.

Dim strResponseData As String = tmpStreamRead.ReadToEnd()

tmpStreamRead.Close()



' Close the response object.

WebResp.Close()



' Get our returned cookie set.

strCookies = CookieJar.GetCookieHeader(AuthURL).ToString()



' Filter for our cadata and session ID cookies.

Dim strCADataCookie As String = Regex.Replace(strCookies,
"(.
 
 
 

webdav error 409 in remote server

Post by Lee Derbys » Fri, 02 Mar 2007 22:49:56

re you remembering to use a unique URL for each item? You may have
found that the code worked one time, then failed each time after that.
The line

strApptItem = "testappointment.eml"

should be replaced with something that ensures that each item URL
changes to something different each time. Maybe build a string using
the current date and time (including seconds) and a random number plus
".eml" tagged on the end, or something.

Lee.

--
_______________________________________

Outlook Web Access For PDA , OWA For WAP
www.owapda.com
email a@t leederbyshire d.0.t c.0.m
_______________________________________

"Jose Manuel Tovar" < XXXX@XXXXX.COM > wrote in message
news:u429w0% XXXX@XXXXX.COM ...
I do
server
String,
strPassword As
(owaauth.dll).
strDomain
vbCrLf +
StreamReader(WebResp.GetResponseStream())
"cadata=" +
" & _
"xmlns:dt=""urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"" " & _
set in
for 24
more
& _
_
dt:dt=""int"">900</cal:reminderoffset>"
Subject</mail:subject>"
here</mail:htmldescription>"
"<g:contentclass>urn:content-classes:appointment</g:contentclass>"
"<e:outlookmessageclass>IPM.Appointment</e:outlookmessageclass>" &
strDomain,
strApptItem), _
to our
network
System.Net.NetworkCredential(strUserName,
NetworkCredential("user",



 
 
 

webdav error 409 in remote server

Post by Jose Manue » Sat, 03 Mar 2007 01:23:43

ee,

Thank you for your interest. I have changed strApptItem and the error
continues even the fisrt time after the change.


"Lee Derbyshire [MVP]" <email a@t leederbyshire d.0.t c.0.m> escribien el
mensaje news: XXXX@XXXXX.COM ... >> Are you remembering to use a unique URL for each item? You may have >> found that the code worked one time, then failed each time after that. >> The line >> >> strApptItem = "testappointment.eml" >> >> should be replaced with something that ensures that each item URL >> changes to something different each time. Maybe build a string using >> the current date and time (including seconds) and a random number plus >> ".eml" tagged on the end, or something. >> >> Lee. >> >> -- >> _______________________________________ >> >> Outlook Web Access For PDA , OWA For WAP >> www.owapda.com >> email a@t leederbyshire d.0.t c.0.m >> _______________________________________ >> >> "Jose Manuel Tovar"<< XXXX@XXXXX.COM >> wrote in message >> news:u429w0% XXXX@XXXXX.COM ... >>> Hello, >>> >>> >>> >>> I am trying to make work the webdav example from: >>> >>> >>> >>> http://msdn2.microsoft.com/en-us/library/ms875692.aspx >>> >>> http://msdn2.microsoft.com/en-us/library/ms877306.aspx >>> >>> >>> >>> (I have form authentication in my Exchange server) >>> >>> >>> >>> I get error in remote Server (409) Conflict >>> >>> >>> >>> I can see in the exchange session init that the program connects but >> I do >>> not know why the error in the final "PROPPATCHRequest.GetResponse()" >>> >>> >>> >>> Thank you in advance. >>> >>> >>> >>> This is the code: >>> >>> >>> >>> >>> >>> Imports System >>> >>> Imports System.Net >>> >>> Imports System.IO >>> >>> Imports System.Xml >>> >>> Imports System.Text.RegularExpressions >>> >>> Imports System.Net.HttpWebRequest >>> >>> >>> >>> Module Module1 >>> >>> >>> >>> 'Implementation of the Authentication to the Exchange Server 2003 >> server >>> that is enabled with forms-based authentication >>> >>> Private Function AuthenticateSecureOWA(ByVal strServerName As >> String, >>> ByVal strDomain As String, ByVal strUserName As String, ByVal >> strPassword As >>> String) As String >>> >>> ' Code to call the Authentication: >>> >>> Dim CookieJar As CookieContainer >>> >>> Dim strCookies As String >>> >>> >>> >>> Dim AuthURL As System.Uri >>> >>> >>> >>> Try >>> >>> ' Construct our destination URI. >>> >>> AuthURL = New System.Uri("https://" + strServerName + >>> "/exchweb/bin/auth/owaauth.dll") >>> >>> Catch ex As Exception >>> >>> MsgBox("Error occurred while you are creating the URI for OWA >>> authentication!" + vbCrLf + vbCrLf + ex.Message) >>> >>> Return "Error" >>> >>> End Try >>> >>> >>> >>> Dim WebReq As HttpWebRequest >>> >>> CookieJar = New CookieContainer >>> >>>