Click here to Skip to main content
15,891,976 members

not redirecting/login to owa

kk2014 asked:

Open original thread
hi all,

i am not able to redirect/login to my owa page. when i run my code below commandd windoe comes and disappears nothing happens.

please seemy code below


Sub main()

    Dim strServerName As String = "12.345.56.789" ' my owa ip
    Dim strPassword As String = "password" 'my password
    Dim strUserName As String = "username" ' my username

    ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack)
    Dim strURL As String = "https://" & strServerName & "/exchange/"
    ''Dim strURL As String = "https://" & strServerName & "/owa/"
    Dim Response As System.Net.HttpWebResponse
    Dim RequestStream As System.IO.Stream
    Dim ResponseStream As System.IO.Stream

    Dim WebReq As HttpWebRequest = CType(System.Net.WebRequest.Create(strURL), System.Net.HttpWebRequest)
    WebReq.Credentials = New System.Net.NetworkCredential(strUserName, strPassword)
    Try
        WebReq.Method = "POST"
        WebReq.ContentType = "text/xml"
        WebReq.KeepAlive = True
        WebReq.AllowAutoRedirect = False


        Dim AuthUrl As System.Uri

        AuthUrl = New System.Uri("https://" + strServerName + "/exchweb/bin/auth/owaauth.dll")
        cookieJar = New CookieContainer

        WebReq.CookieContainer = cookieJar

        Dim strPostFields As String = "destination=https%3A%2F%2F" & strServerName & "%2Fowa%2F"
        Dim PostData() As Byte = System.Text.Encoding.ASCII.GetBytes(strPostFields)

        ' Set the content length.
        WebReq.ContentLength = PostData.Length
        Dim tmpStream As Stream
        Try
            ' Create a request stream. Write the post data to the stream.
            tmpStream = WebReq.GetRequestStream()
            tmpStream.Write(PostData, 0, PostData.Length)
            tmpStream.Close()

        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString())
        End Try


        ' Get the response from the request.
        Dim WebResp As HttpWebResponse = WebReq.GetResponse()
        WebResp.Close()

        'WebReq.Timeout = 30000
        'ResponseStream = WebReq.GetRequestStream()
        'Response1 = WebReq.GetResponse()
    Catch ex As Exception
        MessageBox.Show(ex.Message.ToString())
    End Try

End Sub
Tags: Outlook, Web Development, Redirection, Microsoft Access

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900