automate login w/third party site

heidlipse

New Member
sorry about the repost. I have not had a response from yesterday: original post:<BR><BR>http://www.aspmessageboard.com/forum/ASPPlus.asp?M=492601&T=492601&F=36&P=1<BR><BR>I run an Intranet and have the following problem.... I have a drop down list that has option values like <BR><BR><option value=http://aspmessageboard.com/archive/index.php/"username&#124hash-password">Persons Name</option> <BR><BR>(Nothing sensitive so I am not worried about having the user/pass visible in the code)<BR><BR>I want to have a single click login to UPScampusship.com so I can minimize the number of usernames and passwords 100 employees need to remember. **It is not the UPS website, but a special UPS site for large customers. Unfortunately the UPS site has some .Net tools, but the UPScampusship site does not: <BR><BR>1)User selects name and clicks submit from home page of Intranet<BR>2) data is posted to another intranet page where the username and password are split, loaded into an array, and have the password unhashed.<BR>3) the receiving page turns around and takes ary(0) <-- username and ary(1) <--password and auto-posts to the remote site via https.<BR>4) the data would be posted to the login form process page of UPS and the user would be at this third party site, not on a intranet page-scrape.<BR><BR>I can do steps 1 and 2, but am having the worst time figuring out how to post the data to this other site without screen scraping. In other words I want to auto-post the data and have the new site load in the window not using screen scraping. Is this even possible in .Net?<BR><BR>I have scoured google and groups.google for several hours looking at snips of code that almost do what I want it to, but all seem to be screen scraping, which I do not want. I have also tried to understand the .net class explorer examples to no avail. I'm sure it is simple, at least in classic asp using the MSXML parser it was simple. <BR><BR>Any ideas? <BR><BR>I had one person reply with "what about using a web service".<BR><BR>My response was:<BR><BR>"I don't think a webservice will solve my problem because the remote web site is a third party site and that still does not help me understand how to auto submit the username and password. I just want to know how to auto-post form variables to a third party site so I can log in with one click of a button, without having to have 50 people remembering their usernames and passwords. <BR><BR>In classic ASP you could use the MSXML parser to do a post to a remote site. I can't seem to figure it out in asp.net. <BR><BR>the scenario is that the user selects their location, user clicks a button on my site, username and password are passed to another page to do the split, and then auto submit to form action login page of UPS.<BR><BR>This is the closest I can get using the following code:<BR><BR>Dim req as System.Net.HttpWebRequest <BR> Dim res as System.Net.HttpWebResponse <BR> Dim sr as System.IO.StreamReader <BR> Dim s as System.IO.Stream <BR> Dim b as byte() <BR> <BR> <BR> '--notice that the instance is created using webrequest <BR> '--this is what microsoft recomends <BR> req = System.Net.WebRequest.Create("https://www.upscampusship.com/login2.asp?qD=default") <BR> <BR> 'enncode the form data string into a byte array <BR> b = System.Text.Encoding.ASCII.GetBytes("LoginName=asdfasdf&UserPwd=asdfasdf")<BR><BR>'username and password purposeley written this way so I am not giving it out on the Internet :O)<BR> <BR> 'indicate that you will be posting the data <BR> req.Method = "post" <BR> req.ContentType = "application/x-www-form-urlencoded" <BR> <BR> 'send the form <BR> req.ContentLength = b.Length <BR> s = req.GetRequestStream() <BR> s.Write(b, 0, b.Length) <BR> res = req.GetResponse() <BR> <BR> 'read in the page <BR> sr = new System.IO.StreamReader(res.GetResponseStream()) <BR> Literal1.Text = sr.ReadToEnd <BR> <BR> '--tidy up <BR> sr.Close() <BR> res.Close()
 
Top