Subject: FW: Searching folders with WebDAV

From: "Jim Whitehead" <[email-masked]>
Date: Mon, 21 Jan 2002 11:58:23 -0800

Accidentally caugh by the spam filter.

- Jim

-----Original Message-----
From: Lisa Horton [mailto:[email-masked]]
Sent: Monday, January 21, 2002 8:37 AM
To: [email-masked]
Subject: [Moderator Action] Searching folders with WebDAV

I hope someone can help me with 2 problems I am having with WebDAV.  I am
developing a web page that shows public folder data from our Exchange Server
such as calendar data and contact data.  We access our Exchange Server
through our web server using URLs.  I have had much success using WebDAV,
but have hit a "brick wall" on 2 items which are listed below with code.

1)  I am trying to perform a SEARCH on a public folder using SQL/XML/WebDAV
and I am receiving no response.

CODE:
 dim objXML, strR, strURL, docXML, sReq
    Set objXML = CreateObject("Microsoft.XMLHTTP")
    strURL = "http://mail.agtrax.com/public/AgTrax/web%20Calendar/"
    objXML.open "SEARCH", strURL, False, webExchgUserName, webExchgPassword

    sReq="<?xml version='1.0'?>"
    sReq= sReq & "<a:searchrequest xmlns:a = 'DAV:' >"
    sReq= sReq & "<a:sql>Select 'urn:schemas:calendar:dtstart', "
    sReq= sReq & "'urn:schemas:calendar:location', "
    sReq= sReq & "'urn:schemas:calendar:dtend', "
    sReq= sReq & "'urn:schemas:calendar:alldayevent'"
    sReq= sReq & " FROM Scope('SHALLOW TRAVERSAL OF '" & strURL & "'')"
    sReq= sReq & " WHERE NOT 'urn:schemas:calendar:instancetype' = 1"
    sReq= sReq & " AND 'DAV:contentclass' =
'urn:content-classes:appointment'"
    sReq= sReq & " AND 'urn:schemas:calendar:dtend' &gt;
'2002-02-01T01:00:00.000Z'"
    sReq= sReq & " AND 'urn:schemas:calendar:dtstart' &lt;
'2002-02-28T01:00:00.000Z'"
    sReq= sReq & " ORDER BY 'urn:schemas:calendar:dtstart' DESC"
    sReq= sReq & "</a:sql>"
    sReq= sReq & "</a:searchrequest>"
    objXML.setrequestheader "Translate", "f"
    objXML.setRequestHeader "Content-type:", "text/xml"
    objXML.setRequestHeader "Host:", "mail.agtrax.com"
    objXML.setRequestHeader "Depth", "1"

    objXML.Send (sReq)
    Set docXML = objXML.responseXML

    Dim objNodeAppt, i
    dim objNode
    Set objNodeAppt = docXML.getElementsByTagName("*")
    For i = 0 TO (objNodeAppt.length -1)
      Set objNode = objNodeAppt.nextNode
        Response.Write("<b>" & objNode.NamespaceURI & " " & objNode.NodeName
& "</b> - ")
      Response.Write(objNode.text  & "<hr>")
    Next

2) I am trying to create a contact folder (in Exchange)using MKCOL and I am
receiving the Status Code 403 (Forbidden).  Is this just an issue with
permissions or am I using the wrong method to create a folder?  The code is
below:

CODE:
 dim objXML, strR, docXML
    Set objXML = CreateObject("Microsoft.XMLHTTP")
    strURL = "http://mail.agtrax.com/public/Agtrax/Test Folder"
    objXML.open "MKCOL", strURL, False, webExchgUserName, webExchgPassword
    strR = "<?xml version='1.0'?>"
    strR = strR & "<d:propertyupdate xmlns:d='DAV:'>"
    strR = strR & "<d:set><d:prop>"
    strR = strR & "<d:displayname>Test Folder</d:displayname>"
    strR = strR & "</d:prop></d:set>"
    strR = strR & "</d:propertyupdate>"

    objXML.setRequestHeader "Content-type:", "text/xml"
    objXML.setRequestHeader "Host:", "mail.agtrax.com"
    objXML.Send (strR)
     Set docXML = objXML.responseXML

    Dim objNodeAppt, i
    dim objNode
    Set objNodeAppt = docXML.getElementsByTagName("*")
    For i = 0 TO (objNodeAppt.length -1)
      Set objNode = objNodeAppt.nextNode
        Response.Write("<b>" & objNode.NamespaceURI & " " & objNode.NodeName
& "</b> - ")
      Response.Write(objNode.text  & "<hr>")
    Next

Thanks for your help,
Lisa Horton
AgTrax Technologies
[email-masked]

---

From: "Julian Reschke" <[email-masked]>
Date: Mon, 21 Jan 2002 22:49:46 +0100

>       Response.Write(objNode.text  & "<hr>")

What is the response code you're getting. And what exactly do you get as
reply?

(BTW: the "SQL" search grammar is something proprietay to Microsoft).

> permissions or am I using the wrong method to create a folder?

You can't use MKCOL with a request body. Try again without.

---

From: "Lisa Dusseault" <[email-masked]>
Date: Mon, 21 Jan 2002 16:26:53 -0800

> You can't use MKCOL with a request body. Try again without.

Actually, I believe some Microsoft servers do support MKCOL with a body.
However, this is a non-standard extension of MKCOL, not described in RFC2518
or any other document submitted to the working group or the IETF as far as I
know.  Thus I suspect this working group can't be of much assistance in this
matter.

Lisa

---

From: Joachim Feise <[email-masked]>
Date: Mon, 21 Jan 2002 17:01:38 -0800 (PST)

> know.  Thus I suspect this working group can't be of much assistance in this

Hmm, to quote section 8.3.1 of http://www.ietf.org/rfc/rfc2518.txt:
"A MKCOL request message may contain a message body.  The behavior of
a MKCOL request when the body is present is limited to creating
collections, members of a collection, bodies of members and
properties on the collections or members.  If the server receives a
MKCOL request entity type it does not support or understand it MUST
respond with a 415 (Unsupported Media Type) status code.  The exact
behavior of MKCOL for various request media types is undefined in
this document, and will be specified in separate documents."

-Joe