Re: WebDav Authentication
- From: "Henning Krause [MVP - Exchange]" <newsgroups_remove@xxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Aug 2007 17:53:37 +0200
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
.
- References:
- WebDav Authentication
- From: LisaConsult
- WebDav Authentication
- Prev by Date: WebDav Authentication
- Next by Date: Re: WebDav Authentication
- Previous by thread: WebDav Authentication
- Next by thread: Re: WebDav Authentication
- Index(es):
Relevant Pages
|