Microsoft KB Archive/295408

= PRB: WHERE Clauses with DAV:href Require Relative Paths =

Article ID: 295408

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft Exchange 2000 Server Standard Edition

-



This article was previously published under Q295408



SYMPTOMS
When you use a WHERE clause in a Web Distributed Authoring and Versioning (WebDAV) SEARCH query to restrict the result set based on the DAV:href property, you receive no matching results even though the document that you are searching for does exist.

For example, if you have a public folder tree named Test/Folder/Subfolder that contains a Microsoft Word document named Test.doc, the following WebDAV SEARCH request returns nothing, even though Test.doc exists: Select &quot;DAV:displayname&quot;, &quot;DAV:href&quot;  FROM Scope('SHALLOW TRAVERSAL OF &quot;&quot;') WHERE &quot;DAV:href&quot; = 'http://servername/exchange/test/folder/subfolder/test.doc'



CAUSE
This behavior is by design.



RESOLUTION
To resolve this problem, execute a search with a restriction that contains WHERE &quot;DAV:href&quot; = 'value' only if the value is a relative URL.

For example, in the public folder tree scenario, the following SEARCH Request returns the record that is related to Test.doc: Select &quot;DAV:displayname&quot;, &quot;DAV:href&quot;  FROM Scope('SHALLOW TRAVERSAL OF &quot;&quot;')  WHERE &quot;DAV:href&quot; = '/test/folder/subfolder/test.doc'



Steps to Reproduce Behavior
 Create a public folder tree named Test/Folder/Subfolder, and create a Word document named Test.doc in the Subfolder folder. In Microsoft Visual Basic, create a Standard EXE project. Form1 is created by default. Add a button to Form1.  Paste the following code in the Click event of the button: Dim oDoc As MSXML.DOMDocument Dim oDocBack As MSXML.DOMDocument

Dim oNode As IXMLDOMElement Dim oNode2 As IXMLDOMElement Dim req As MSXML.XMLHTTPRequest

Dim strURL As String Dim sUserID As String Dim sPassword As String

'TO DO: Change the server name in the URL below to reflect your server. strURL = &quot;http://Servername/test/folder1/subfolder1/&quot;

'TO DO: Change the userid and the password below to reflect your userid and password. sUserID = &quot;user1&quot; sPassword = &quot;password&quot;

Set oDoc = CreateObject(&quot;MICROSOFT.XMLDOM&quot;) Set oDocBack = CreateObject(&quot;MICROSOFT.XMLDOM&quot;) Set pi = oDoc.createProcessingInstruction(&quot;xml&quot;, &quot;version=&quot;&quot;1.0&quot;&quot;&quot;) oDoc.appendChild pi

Set oNode = oDoc.createNode(1, &quot;searchrequest&quot;, &quot;DAV:&quot;) Set oDoc.documentElement = oNode

Set oNode2 = oDoc.createNode(1, &quot;sql&quot;, &quot;DAV:&quot;) oNode.appendChild oNode2

'SEARCH LINE 1 'TO DO: Change the server name in the line below to   'reflect your Exchange server. strQuery = &quot;Select &quot;&quot;DAV:displayname&quot;&quot;, &quot;&quot;DAV:href&quot;&quot; From &quot; strQuery = strQuery & &quot;Scope('Deep Traversal of &quot;&quot;&quot; & strURL & &quot;&quot;&quot;') &quot; strQuery = strQuery & &quot;WHERE &quot;&quot;DAV:href&quot;&quot; = &quot; strQuery = strQuery & _ &quot;'http://Servername/test/folder/subfolder/Test.doc'&quot; 'SEARCH LINE 2 '  strQuery = &quot;Select &quot;&quot;DAV:displayname&quot;&quot;, &quot;&quot;DAV:href&quot;&quot; From &quot; '  strQuery = strQuery & &quot;Scope('Deep Traversal of &quot;&quot;&quot; & strURL & &quot;&quot;&quot;') &quot; '  strQuery = strQuery & &quot;WHERE &quot;&quot;DAV:href&quot;&quot; = &quot; '  strQuery = strQuery & _ '    &quot;'/folder/subfolder/Test.doc'&quot; Set query = oDoc.createTextNode(strQuery) oNode2.appendChild query

Set req = CreateObject(&quot;microsoft.xmlhttp&quot;) req.open &quot;SEARCH&quot;, strURL, False, sUserID, sPassword req.setRequestHeader &quot;Translate&quot;, &quot;f&quot; req.setRequestHeader &quot;Content-Type&quot;, &quot;text/xml&quot; req.setRequestHeader &quot;Depth&quot;, &quot;0&quot; req.send oDoc

Set oDocBack = req.responseXML

Dim objNodeList

'The DAV namespace typically uses the 'a' prefix. 'If you are specifying multiple properties in a search, examine the 'returned XML beforehand to determine prefixes for your code.

Set objNodeList = oDocBack.getElementsByTagName(&quot;a:href&quot;) For i = 0 To (objNodeList.length - 1) Set objNode = objNodeList.nextNode MsgBox objNode.Text Next </li> Search for lines in the code that are marked &quot;TO DO&quot; and modify them according to your situation.</li> Add a reference to the Microsoft XML version 2.0 library.</li> Run the project. Note that no results are returned.</li> Change the code by commenting out the the lines below the &quot;SEARCH LINE 1&quot; comment, and uncomment the lines under the &quot;SEARCH LINE 2&quot; comment.</li> Run the code again. Note that the DAV:href property for the Text.doc file that exists in the Subfolder folder is returned.</li></ol>

NOTE: The above code does not reproduce the behavior if the search is done against the default Public Folders store.

Keywords: kbmsg kbprb KB295408

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.