Re: WebDav Authentication

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello,

could you please post the complete exception info (Message + Stacktrace)?

Kind regards,
Henning Krause

"LisaConsult" <lisasconsult@xxxxxxxxxxxxx> wrote in message news:F5B1E2F2-0A4F-4AC4-A2AF-538B4BF1B73F@xxxxxxxxxxxxxxxx
I'm attempting to write a WebDAV to access contacts, but it is failing when I
try the authentication. I receive a WebException and InvalidCastException
conversion from string to double where indicated below (GetResponse). I've
verified the path to the DLL and the server/path works in the browser on the
server. I'm using the administrator login. It's on Win2003SBS. Any
assistance is appreciated. Thanks, Lisa

Public class clsWebDAVInterface
private strServer as string = "http://SERVER.COM";
private strPath as string= "/exchange/USERi/inbox"
private strUsername as string = "administrator"
private strPassword as string = "PASSWORD"
private authCookies as CookieCollection = nothing
private m_objCredentials as NetworkCredential

Public sub Authenticate()

Dim strAuthURI as String = strServer + "/exchweb/bin/auth/owaauth.dll"
Dim strBody as String
Dim bytBody as Byte()
Dim objRequest as HttpWebRequest
dim objResponse as HttpWebResponse
Dim objStream as Stream

m_objCredentials = new NetworkCredential(strUserName, strPassword,
"DOMAIN.COM")
'Create the web request body:
strBody = "destination=" & strServer & strPath & "&username=" &
strUsername & "&password=" & strPassword
bytBody = Encoding.UTF8.GetBytes(strBody )
'Create the web request:

objRequest = CType(System.Net.WebRequest.Create( strAuthURI
),HttpWebRequest)
objRequest.Credentials = m_objCredentials
objRequest.Method = "POST"
objRequest.ContentType = "application/x-www-form-urlencoded"
objRequest.CookieContainer = new CookieContainer()
objRequest.ContentLength = bytBody.Length

'Create the web request content stream:
objStream = objRequest.GetRequestStream()
objStream.Write( bytBody, 0, bytBody.Length )
objStream.Close()

'Get the response & store the authentication cookies:
Console.Writeline("Next statement dies")
objResponse = objRequest.GetResponse()
Console.Writeline("Does not get here")
if (objResponse.Cookies.Count < 2 ) then
throw new AuthenticationException("Login failed. Is the login /
password correct?")
end if

authCookies = new CookieCollection()
for each myCookie as Cookie in objResponse.Cookies
authCookies.Add( myCookie )
Next

objResponse.Close()
End Sub
Public Shared Sub Main(ByVal args() as String )

Dim objRequest as clsWebDAVInterface
try
objRequest = new clsWebDAVInterface()
objRequest.Authenticate()
catch e as AuthenticationException
Console.WriteLine( "Authentication Exception, are you using a valid
login?" )
Console.WriteLine( " Msg: " + e.Message )
Console.WriteLine( " Note: You must use a valid login / password
for authentication." )
catch e as WebException
Console.WriteLine( "Web Exception" )
Console.WriteLine( " Status: " + e.Status )
Console.WriteLine( " Reponse: " + e.Response.ToString )
Console.WriteLine( " Msg: " + e.Message )
catch e as Exception
Console.WriteLine( "Unknown Exception" )
Console.WriteLine( " Msg: " + e.Message )

End try
End sub
End Class


.



Relevant Pages

  • Re: Net.WebRequest/WebResponse ?s
    ... if the exception is a "WebExceptionStatus.ProtocolError" the exception variable will contain a pointer to an HTTPWebResponse object that can be used to get at the values I needed! ... Dim ErrResult As String = New ... Public Function GetResponsePWP(ByVal ReqURL As String, ByVal ReqTimeout As Integer, ByVal ReqType As String, ByVal PostData As String, ByVal UserName As String, ByVal Password As String) As String ... Dim nmsStatusCode As String = "" ...
    (microsoft.public.dotnet.languages.vb)
  • Re: TRUSTED_CONNECTION = NO geht nicht bei eingebundenen Tabellen
    ... Authentication umgeschaltet, dann bleibt es normalerweise auch dabei, auch wenn die Windows ... Dim dbs As DAO.Database ... Dim sql As String, sPkIndexName As String ... If rs.EOF Then GoTo Exit_ ...
    (microsoft.public.de.access.clientserver)
  • Attempted to read or write protected memory (vb.Net 2005)
    ... When I excute the below code I get an exception. ... Dim lconn As New OleDb.OleDbConnection ... Dim lstrsql As String ...
    (microsoft.public.vsnet.general)
  • DES ECB Encryption cannot decrypt
    ... If I have the value to encrypt = ... Dim globalexception As CryptographicException ... Public Function encrypt(ByRef textPIN As String, ByRef textKey As String, ... Catch exception As CryptographicUnexpectedOperationException ...
    (microsoft.public.dotnet.security)
  • Re: PathTooLongException auswerten
    ... daher auch der erwartete Fehler. ... welchem es zu der Exception kam, hast Du dann ja in Deiner ... Dim NL as String = ControlChars.CrLf ...
    (microsoft.public.de.german.entwickler.dotnet.vb)