Login | |
|
 |
RE: Re: Downloading a file - 7/31/2005 6:41:43 PM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Yet another follow up: Here's the new approach: '/////////////////////////////////////////////////////// '// Microsoft created several objects, which let's '// you read remote binary and text files. First of '// them was Microsoft.XMLHTTP - the object is using '// WinINET API, so there is no good idea to use it on '// server-side ASP script. Thanks to WinINET API, '// XMLHTTP has a great functionality - it supports any '// URL - http, https, ftp and gopher. The URL looks like '// protocol://usename:password@server/folder/file?parameters. '// Other MS HTTP objects are using new WinHTTP interface. '// There are three object you can use: '// MSXML2.ServerXMLHTTP '// WinHttp.WinHttpRequest.5 '// WinHttp.WinHttpRequest '// ServerXMLHTTP and WinHttpRequest objects has a lot of '// properties and methods, which let's you specify proxy, '// additional request headers and so on. '// You can download latest versions of WinHttp objects from '// msdn site, they are also included in some windows service '// packs and new windows versions. '/////////////////////////////////////////////////////////// Function BinaryGetURL(URL) 'Create an Http object, use any of the four objects Dim Http ' Set Http = CreateObject("Microsoft.XMLHTTP") ' Set Http = CreateObject("MSXML2.ServerXMLHTTP") Set Http = CreateObject("WinHttp.WinHttpRequest.5.1") ' Set Http = CreateObject("WinHttp.WinHttpRequest") 'Send request To URL Http.Open "GET", URL, False ' HttpReq.SetClientCertificate "???????" Http.Send 'Get response data As a string BinaryGetURL = Http.ResponseBody MsgBox(BinaryGetURL) End Function BinaryGetURL("https://") how can I get this to work if a client certificate is not required but if the site asks for one anyway?
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Re: Downloading a file - 8/1/2005 7:11:06 AM
|
|
 |
|
| |
Fredledingue
Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
Hi, I can't use any of these codes because it can't createobject("Adodb.Stream") . Is there a way that I can get it working? I'm on w98se.
_____________________________
Fred
|
|
| |
|
|
|
 |
RE: Re: Downloading a file - 8/1/2005 11:12:01 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
You can download the latest version of ADO at: http://www.microsoft.com/data/
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Re: Downloading a file - 10/20/2005 5:36:23 AM
|
|
 |
|
| |
Snipah
Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
TNO, I have found some info on ExpertExchange.. hope it helps some.... QUOTE: you can try following, which sends requests to the server and I think (I'm not sure though) that after this as soon as you navigate to second domain it should identify you, remeber that you also have to authenticate user either by values sent thru "url" variable's query strings or just "Request.Form("txtUsername")" and Request.Form("txtPassword") sent by http://www.ourdomain.com/login.asp and POST method in WinHttp.WinHttpRequest.5.1 authentication must be done at same time, i.e. when you authenticate user in ourdomain.com it also has to be authenticated in theirdomain.com, and it will be good if you keep Session.TimeOut property same for both domain so that when sessions time out in one domain they don't stay in second Dim url = "http://www.theirdomain.com/login.asp?username=uName?password=pwd" Set myReq = Server.CreateObject("WinHttp.WinHttpRequest.5.1") myReq.Open("POST", url, false) myReq.setRequestHeader("Accept-Language", "en-us") ' --> or Request.ServerVariable("HTTP_ACCEPT_LANGUAGE") myReq.setRequestHeader("Connection", "Keep-Alive") myReq.setRequestHeader("Referer", "http://www.ourdomain.com/login.asp") myReq.setRequestHeader("User-Agent", Request.ServerVariable("USER_AGENT")) ' --> or HTTP_USER_AGENT myReq.setRequestHeader("Accept-Encoding", "gzip, deflate") ' --> or Request.ServerVariable("HTTP_ACCEPT_ENCODING") myReq.setRequestHeader("Cache-Control", "no-cache") myReq.setRequestHeader("Cookie", "Username=" & Request.Form("txtUsername") & "; domain=.theirdomain.com;path=/;HTTPOnly= ;version=1") myReq.setRequestHeader("Cookie", "Password=" & Request.Form("txtPassword") & "; domain=.theirdomain.com;path=/;HTTPOnly= ;version=1") myReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") myReq.setRequestHeader.Send(url) if this solves you problem you should remember that authentication without SSL is a security risk and you must take it very seriously, if you do then consider doing it like this Dim url = "https://www.theirdomain.com/login.asp?username=uName?password=pwd" ' --> note that it's not HTTP:// Set myReq = Server.CreateObject("WinHttp.WinHttpRequest.5.1") myReq.SetClientCertificate("LOCAL_MACHINE\Personal\My Middle-Tier Certificate") and everything else will be the same, for more info about this read msdn documentation at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/iwinhttprequest_setclientcertificate.asp there's also a slightly different way of doing this and that is, instead of "WinHttp.WinHttpRequest.5.1" you would use "MSXML2.ServerXMLHTTP.4.0" and instead of "SetClientCertificate" you would use "setOption" method like so and everything else would stay the same Const SXH_OPTION_SELECT_CLIENT_SSL_CERT = 3 Dim url = "https://www.theirdomain.com/login.asp?username=uName?password=pwd" ' --> note that it's not HTTP:// Set myReq = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0") myReq.SetOption(SXH_OPTION_SELECT_CLIENT_SSL_CERT, "certificateName") [from msdn website] SXH_OPTION_SELECT_CLIENT_SSL_CERT By default, the value of this option is an empty string (""), which means pick the first certificate in the local store to send if the server requests a client certificate. The SXH_OPTION_SELECT_CLIENT_SSL_CERT option is a string that lets you select which client certificate from the local store should be sent. You must set this option before calling the send method. The following example sets the client certificate option to request the client certificate named "MSXML": shx.setOption(3, "MSXML") [end] however there was a bug in "MSXML2.ServerXMLHTTP" and I don't know if that bug was fixed in "MSXML2.ServerXMLHTTP.4.0", also remember that 4.0 version is not installed in any win 2000 so you need to install it from microsoft website! I heard that lots of bugs were fixed in the new version so I would strongly recommend to download and install it [MSXML2.ServerXMLHTTP bug into] http://support.microsoft.com/default.aspx?scid=kb;EN-US;q290899
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|