Sure, here is the test code I'm using:
Private Sub Test()
' Variables
Dim Request As System.Net.HttpWebRequest
Dim Response As System.Net.HttpWebResponse
Dim MyCredentialCache As System.Net.CredentialCache
Dim strPassword As String
Dim strDomain As String
Dim strUserName As String
Dim strRootURI As String
Dim strQuery As String
Dim bytes() As Byte
Dim RequestStream As System.IO.Stream
Dim ResponseStream As System.IO.Stream
Dim ResponseXmlDoc As System.Xml.XmlDocument
Dim DisplayNameNodes As System.Xml.XmlNodeList
Try
' Initialize variables.
strUserName = "exchange"
strPassword = "exchange"
strDomain = "Fladgate"
'strRootURI = "http://uranus/public/Fladgate Training - IT"
'strRootURI = "http://uranus/public"
strRootURI = "http://uranus/exchange/chumphreys/calendar"
' Build the SQL query.
strQuery = "<?xml version=""1.0""?>" & _
"<D:searchrequest xmlns:D = ""DAV:"" >" & _
"<D:sql>SELECT ""DAV:displayname"" FROM """ & strRootURI &
"""" & _
"WHERE ""DAV:ishidden"" = false AND ""DAV:isfolder"" = false"
& _
"</D:sql></D:searchrequest>"
' Create a new CredentialCache object and fill it with the network
' credentials required to access the server.
MyCredentialCache = New System.Net.CredentialCache
MyCredentialCache.Add(New System.Uri(strRootURI), _
"NTLM", _
New System.Net.NetworkCredential(strUserName, strPassword,
strDomain) _
)
' Create the PUT HttpWebRequest object.
Request = CType(System.Net.WebRequest.Create(strRootURI), _
System.Net.HttpWebRequest)
' Add the network credentials to the request.
Request.Credentials = MyCredentialCache
' Specify the SEARCH method.
Request.Method = "SEARCH"
' Encode the body using UTF-8.
bytes = System.Text.Encoding.UTF8.GetBytes(strQuery)
' Set the content header length. This must be
' done before writing data to the request stream.
Request.ContentLength = bytes.Length
' Get a reference to the request stream.
RequestStream = Request.GetRequestStream()
' Write the message body to the request stream.
RequestStream.Write(bytes, 0, bytes.Length)
' Close the Stream object to release the connection
' for further use.
RequestStream.Close()
' Set the Content Type header.
Request.ContentType = "text/xml"
' Set the Translate header.
Request.Headers.Add("Translate", "F")
' Send the SEARCH method request and get the
' response from the server.
Response = CType(Request.GetResponse(),
System.Net.HttpWebResponse)
' Get the XML response stream.
ResponseStream = Response.GetResponseStream()
' Create the XmlDocument object from the XML response stream.
ResponseXmlDoc = New System.Xml.XmlDocument
ResponseXmlDoc.Load(ResponseStream)
' Build a list of the DAV:href XML nodes, corresponding to the
folders
' in the mailbox. The DAV: namespace is typically assgigned the
a:
' prefix in the XML response body.
DisplayNameNodes =
ResponseXmlDoc.GetElementsByTagName("a:displayname")
' Loop through the returned items (if any).
If DisplayNameNodes.Count > 0 Then
Console.WriteLine("Non-folder item display names...")
MsgBox("Non-folder item display names...")
Dim i As Integer
For i = 0 To DisplayNameNodes.Count - 1
' Display the non-folder item displayname.
Console.WriteLine(DisplayNameNodes(i).InnerText)
Next
Else
Console.WriteLine("No non-folder items found...")
MsgBox("No non-folder items found...")
End If
' Clean up.
ResponseStream.Close()
Response.Close()
Catch ex As Exception
' Catch any exceptions. Any error codes from the
' SEARCH method requests on the server will be caught
' here, also.
Console.WriteLine(ex.Message)
MsgBox(ex.Message)
End Try
End Sub
> Hello,
>
[quoted text clipped - 45 lines]
> > Thanks
> > Jeanine
Henning Krause [MVP - Exchange] - 18 Apr 2007 22:09 GMT
Very strange..
the code runs perfectly against my test exchange server (which ist exchange
2003, sp2). No bad request at all...
I have currently no further idea here...
Henning
> Sure, here is the test code I'm using:
>
[quoted text clipped - 184 lines]
>> > Thanks
>> > Jeanine
Jeanine - 19 Apr 2007 09:28 GMT
Hi, thanks for trying it out. At least that proves its not my code and must
be something on our server.
Jeanine
> Very strange..
>
[quoted text clipped - 193 lines]
> >> > Thanks
> >> > Jeanine
Jeanine - 20 Apr 2007 09:52 GMT
I have tried the code using on an exchange 2000 server and it works
perfectly. So the problem is when it runs on our exchange 2003 SP 2 server.
Any more suggestions?
Thanks
Jeanine
> Hi, thanks for trying it out. At least that proves its not my code and must
> be something on our server.
[quoted text clipped - 198 lines]
> > >> > Thanks
> > >> > Jeanine