Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: WHERE Clauses with DAV:href Require Relative Paths


View products that this article applies to.

This article was previously published under Q295408

↑ Back to the top


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 "DAV:displayname", "DAV:href" <BR/>
FROM Scope('SHALLOW TRAVERSAL OF ""')<BR/>
WHERE "DAV:href" = 'http://servername/exchange/test/folder/subfolder/test.doc'
				

↑ Back to the top


Cause

This behavior is by design.

↑ Back to the top


Resolution

To resolve this problem, execute a search with a restriction that contains WHERE "DAV:href" = '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 "DAV:displayname", "DAV:href" <BR/>
FROM Scope('SHALLOW TRAVERSAL OF ""') <BR/>
WHERE "DAV:href" = '/test/folder/subfolder/test.doc'
				

↑ Back to the top


More information

Steps to Reproduce Behavior

1.Create a public folder tree named Test/Folder/Subfolder, and create a Word document named Test.doc in the Subfolder folder.
2.In Microsoft Visual Basic, create a Standard EXE project. Form1 is created by default.
3.Add a button to Form1.
4.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 = "http://Servername/test/folder1/subfolder1/"

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

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

   Set oNode = oDoc.createNode(1, "searchrequest", "DAV:")
   Set oDoc.documentElement = oNode

   Set oNode2 = oDoc.createNode(1, "sql", "DAV:")
   oNode.appendChild oNode2

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

   Set req = CreateObject("microsoft.xmlhttp")
   req.open "SEARCH", strURL, False, sUserID, sPassword
   req.setRequestHeader "Translate", "f"
   req.setRequestHeader "Content-Type", "text/xml"
   req.setRequestHeader "Depth", "0"
   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("a:href")
 
   For i = 0 To (objNodeList.length - 1)
     Set objNode = objNodeList.nextNode
     MsgBox objNode.Text
   Next
					
5.Search for lines in the code that are marked "TO DO" and modify them according to your situation.
6.Add a reference to the Microsoft XML version 2.0 library.
7.Run the project. Note that no results are returned.
8.Change the code by commenting out the the lines below the "SEARCH LINE 1" comment, and uncomment the lines under the "SEARCH LINE 2" comment.
9.Run the code again. Note that the DAV:href property for the Text.doc file that exists in the Subfolder folder is returned.
NOTE: The above code does not reproduce the behavior if the search is done against the default Public Folders store.

↑ Back to the top


Keywords: KB295408, kbprb, kbmsg

↑ Back to the top

Article Info
Article ID : 295408
Revision : 3
Created on : 2/22/2007
Published on : 2/22/2007
Exists online : False
Views : 261