error 401 using webdav to connect to exchange server 2007 RRS feed

  • Question

  • Connecting to exchange using webdav gives me error 401.

    This is my code to authenticate


     Public p_strUserName As String = ""

        Public p_strPassword As String = "xxxxxxxx"

        Public p_strAlias As String = ""

        Public p_strInboxURL As String = "Inbox"

        Public p_strServer As String = "https://TLSSRV01.tal.local"

        Public p_strDrafts As String = "drafts"

    This is function


     Public Function GetAllMailboxInfo() As XmlDocument

            Dim loXmlDoc As New XmlDocument()


            Dim lsRootUri As String = p_strServer & "/Exchange/" & p_strAlias & "/" & p_strInboxURL

            Dim buffer As Byte() = GetFolderSizeRequest(lsRootUri)

            Dim request = DirectCast(WebRequest.Create(lsRootUri), HttpWebRequest)

            request.Method = "SEARCH"

            request.ContentType = "text/xml"

            request.Credentials = New NetworkCredential(p_strUserName, p_strPassword, "tales")

            request.Headers.Add("Translate", "f")

            request.Headers.Add("Depth", "1")

            Using stream As Stream = request.GetRequestStream()

                stream.Write(buffer, 0, buffer.Length)

            End Using

            Dim loResponse As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)

            Dim loResponseStream As Stream = loResponse.GetResponseStream()


            Return loXmlDoc

        End Function



    On server basic authentication an windows authentication is enabled.




    Thursday, May 19, 2011 12:35 PM