Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Wed, 22 Aug 2007 08:14:03 -0700,    group: microsoft.public.exchange2000.development        back       


WebDav Authentication   
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
date: Wed, 22 Aug 2007 08:14:03 -0700   author:   LisaConsult am

Re: WebDav Authentication   
Hello,

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

Kind regards,
Henning Krause

"LisaConsult" <lisasconsult@online.nospam> wrote in message 
news:F5B1E2F2-0A4F-4AC4-A2AF-538B4BF1B73F@microsoft.com...
> 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
>
date: Wed, 22 Aug 2007 17:53:37 +0200   author:   Henning Krause [MVP - Exchange]

Re: WebDav Authentication   
Thank you for the quick reply, here's the exception info:
Web Exception

Unhandled Exception: System.InvalidCastException: Conversion from string "   
Sta
tus: " to type 'Double' is not valid. ---> System.FormatException: Input 
string
was not in a correct format.
   at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String 
Valu
e, NumberFormatInfo NumberFormat)
   at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String 
Value,
NumberFormatInfo NumberFormat)
   --- End of inner exception stack trace ---
   at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String 
Value,
NumberFormatInfo NumberFormat)
   at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String 
Value)
   at webDAV.clsWebDAVInterface.Main(String[] args)
date: Wed, 22 Aug 2007 09:42:03 -0700   author:   LisaConsult am

Re: WebDav Authentication   
Hello Lisa,

do you have the "Option Strict" enabled for your code? The stack trace seems 
to indicate that this is not the case.

Albeit from that, I don't really see why the specified line of code should 
throw an exception. I would say you need a type casting to HttpWebResponse 
(since the GetResponse returns a WebResponse instance).

Kind regards,
Henning Krause

"LisaConsult" <lisasconsult@online.nospam> wrote in message 
news:DE0BC8D4-CF92-4294-9E24-8DF22F09987F@microsoft.com...
> Thank you for the quick reply, here's the exception info:
> Web Exception
>
> Unhandled Exception: System.InvalidCastException: Conversion from string "
> Sta
> tus: " to type 'Double' is not valid. ---> System.FormatException: Input
> string
> was not in a correct format.
>   at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String
> Valu
> e, NumberFormatInfo NumberFormat)
>   at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String
> Value,
> NumberFormatInfo NumberFormat)
>   --- End of inner exception stack trace ---
>   at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String
> Value,
> NumberFormatInfo NumberFormat)
>   at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String
> Value)
>   at webDAV.clsWebDAVInterface.Main(String[] args)
>
date: Wed, 22 Aug 2007 23:12:06 +0200   author:   Henning Krause [MVP - Exchange]

Re: WebDav Authentication   
Henning, 

Thank you for your assistance.  I set Option Strict on (it wasn't my default 
on a new project....now it is).  I'm now receiving the following error:
Web Exception
   Status: ProtocolError
   Reponse: System.Net.HttpWebResponse
   Msg: The remote server returned an error: (405) Method Not Allowed.

--I am running the process on the server that is running exchange (although 
I am doing so which logged into RDC).  I searched for additional information 
on the web (and found a few of your responsess) but didn't find anything 
similar.  Could you please advise further?  Thank you.
date: Wed, 22 Aug 2007 19:06:00 -0700   author:   LisaConsult am

Re: WebDav Authentication   
Hello,

is the exception still thrown in the same line? Or did you get path the 
FormBased authentication?

Kind regards,
Henning Krause

"LisaConsult" <lisasconsult@online.nospam> wrote in message 
news:1A0B78AB-B88E-44F2-904A-3C0FCFBA5C8D@microsoft.com...
> Henning,
>
> Thank you for your assistance.  I set Option Strict on (it wasn't my 
> default
> on a new project....now it is).  I'm now receiving the following error:
> Web Exception
>   Status: ProtocolError
>   Reponse: System.Net.HttpWebResponse
>   Msg: The remote server returned an error: (405) Method Not Allowed.
>
> --I am running the process on the server that is running exchange 
> (although
> I am doing so which logged into RDC).  I searched for additional 
> information
> on the web (and found a few of your responsess) but didn't find anything
> similar.  Could you please advise further?  Thank you.
date: Thu, 23 Aug 2007 18:06:51 +0200   author:   Henning Krause [MVP - Exchange]

Re: WebDav Authentication   
Henning,
It is still throwing the exception at the same line. The previous exception 
was due to the format of the Error handling.  Now that it's resolved, I see 
the actual error I was getting all along.
date: Thu, 23 Aug 2007 09:26:03 -0700   author:   LisaConsult am

Re: WebDav Authentication   
Ah... I see the error now.

FBA requires SSL. So you must change your web address from http://server.com 
to https://server.com

Kind regards,
Henning Krause

"LisaConsult" <lisasconsult@online.nospam> wrote in message 
news:5644672A-E69B-4557-9970-2A67D53B3BBC@microsoft.com...
> Henning,
> It is still throwing the exception at the same line. The previous 
> exception
> was due to the format of the Error handling.  Now that it's resolved, I 
> see
> the actual error I was getting all along.
date: Thu, 23 Aug 2007 18:33:12 +0200   author:   Henning Krause [MVP - Exchange]

Re: WebDav Authentication   
But I don't have SSL on this server.  When I try those connections using 
https vs http, they don't work.  Do I have to have SSL? Do I have any other 
options?  Thanks.
date: Thu, 23 Aug 2007 10:06:01 -0700   author:   LisaConsult am

Re: WebDav Authentication   
Hello,

if you access your server via browser, do you use the http url?

Exchange does not allow FBA over an unsecured connection by default.

Kind regards,
Henning Krause

"LisaConsult" <lisasconsult@online.nospam> wrote in message 
news:5FBB71A3-811E-40C3-9EE5-D3EE67CE1F4A@microsoft.com...
> But I don't have SSL on this server.  When I try those connections using
> https vs http, they don't work.  Do I have to have SSL? Do I have any 
> other
> options?  Thanks.
>
date: Thu, 23 Aug 2007 19:12:04 +0200   author:   Henning Krause [MVP - Exchange]

Re: WebDav Authentication   
Hello, Sorry for the delay in a reply.  I was temporarily on another project. 
 I believe I'm confused as most of the examples I've found use http, not 
https with webdav.  All I want to do is run an exe on the server which is 
running Server 2003 and Exchange.  Eventually I'd like it to run as a service 
on the server.  What I'm trying to do is just be able to execute a process 
which will read records from a SQL2000 table which has name email address and 
then insert them into an Exchange public folder so that our data entry system 
e-mail address will appear in exchange.  Is webdav the correct solution?
date: Thu, 30 Aug 2007 11:46:04 -0700   author:   LisaConsult am

Re: WebDav Authentication   
Hello,

yes, WebDAV is a suitable solution for this.

If you connect to Outlook Web Acces, which url do you enter into the 
browser? The folder can be accessed by WebDAV with exactly the same folder.

Kind regards,
Henning Krause

"LisaConsult" <lisasconsult@online.nospam> wrote in message 
news:FC465A1D-286A-4EAC-BD48-821CFD05E079@microsoft.com...
> Hello, Sorry for the delay in a reply.  I was temporarily on another 
> project.
> I believe I'm confused as most of the examples I've found use http, not
> https with webdav.  All I want to do is run an exe on the server which is
> running Server 2003 and Exchange.  Eventually I'd like it to run as a 
> service
> on the server.  What I'm trying to do is just be able to execute a process
> which will read records from a SQL2000 table which has name email address 
> and
> then insert them into an Exchange public folder so that our data entry 
> system
> e-mail address will appear in exchange.  Is webdav the correct solution?
>
date: Thu, 30 Aug 2007 21:07:57 +0200   author:   Henning Krause [MVP - Exchange]

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us