exchangefreaks.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

WebDav Authentication

 
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange 2000 Development
Author Message
LisaConsult



Joined: 22 Aug 2007
Posts: 5

PostPosted: Wed Aug 22, 2007 12:14 pm    Post subject: WebDav Authentication Reply with quote

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

Archived from group: microsoft>public>exchange2000>development
Back to top
View user's profile Send private message
Henning Krause [MVP - Exc



Joined: 05 Aug 2007
Posts: 142

PostPosted: Wed Aug 22, 2007 9:53 pm    Post subject: Re: WebDav Authentication Reply with quote

Hello,

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

Kind regards,
Henning Krause

"LisaConsult" wrote in message @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
>
Back to top
View user's profile Send private message
LisaConsult



Joined: 22 Aug 2007
Posts: 5

PostPosted: Wed Aug 22, 2007 1:42 pm    Post subject: Re: WebDav Authentication Reply with quote

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)
Back to top
View user's profile Send private message
Henning Krause [MVP - Exc



Joined: 05 Aug 2007
Posts: 142

PostPosted: Thu Aug 23, 2007 3:12 am    Post subject: Re: WebDav Authentication Reply with quote

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" wrote in message @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)
>
Back to top
View user's profile Send private message
LisaConsult



Joined: 22 Aug 2007
Posts: 5

PostPosted: Wed Aug 22, 2007 11:06 pm    Post subject: Re: WebDav Authentication Reply with quote

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.
Back to top
View user's profile Send private message
Henning Krause [MVP - Exc



Joined: 05 Aug 2007
Posts: 142

PostPosted: Thu Aug 23, 2007 10:06 pm    Post subject: Re: WebDav Authentication Reply with quote

Hello,

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

Kind regards,
Henning Krause

"LisaConsult" wrote in message @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.
Back to top
View user's profile Send private message
LisaConsult



Joined: 22 Aug 2007
Posts: 5

PostPosted: Thu Aug 23, 2007 1:26 pm    Post subject: Re: WebDav Authentication Reply with quote

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.
Back to top
View user's profile Send private message
Henning Krause [MVP - Exc



Joined: 05 Aug 2007
Posts: 142

PostPosted: Thu Aug 23, 2007 10:33 pm    Post subject: Re: WebDav Authentication Reply with quote

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" wrote in message @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.
Back to top
View user's profile Send private message
LisaConsult



Joined: 22 Aug 2007
Posts: 5

PostPosted: Thu Aug 23, 2007 2:06 pm    Post subject: Re: WebDav Authentication Reply with quote

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.
Back to top
View user's profile Send private message
Henning Krause [MVP - Exc



Joined: 05 Aug 2007
Posts: 142

PostPosted: Thu Aug 23, 2007 11:12 pm    Post subject: Re: WebDav Authentication Reply with quote

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" wrote in message @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.
>
Back to top
View user's profile Send private message
Henning Krause [MVP - Exc



Joined: 05 Aug 2007
Posts: 142

PostPosted: Fri Aug 31, 2007 1:07 am    Post subject: Re: WebDav Authentication Reply with quote

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" wrote in message @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?
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
WEBDAV: how to get a Multiline body in webdav created appoin I am using webdav to create an appointment and post it to a clanedar. When I pass a regular string with carriage returns and linefeeds to the field they do not display. If I try to pass an html formatted string in the fie

PROPPATCH method - webdav again.. Hello All, I am trying to create a contact in user's contacts folder using webdav and java. I wrote something similar to: but I get: HTTP/1.1 400 Bad Request. I don't know if I understand properly xml schema used in

webdav = get the description of an event in Exchange Hi there, Im trying to display the description or message (subject, dtstart, dtend are all ok) of a calendar entry but I cannot find which schema it belongs to; Is it: or: or: urn:sc

Tom or Mindy? Create IPM.DistList with WebDav and VB.NET?? Hi. Would be very grateful if anyone could point me in the right direction... I am trying to create a personal distribution list in a users contacts folder with webdav (Why is this so carefully left out of the Exchange SDK?) I figured out that http://sche

How to send message with embbeeded images using WebDAV? Hello, How do i send message with embeeded images using WebDAV? In outlook i need to set the CID field of the attachemnt and than using
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange 2000 Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group