Pass login info from one website to a login popup on another?

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
Trying to help a friend out and I'm totally lost - I have some login credentials stored in a database, along with links to sites.

When you first go to these sites they display a popup login box that you need to fill out before you can get into the site.

What I need to do is send the username/password to this popup, so they user doesn't have to.

Security lectures aside (I know, the users should probably just remember their goddamn passwords for these other sites), does anybody know how I'd go about doing this?

The originating site is in C#/ASP.NET, I have no idea what language(s) the target sites are in.
 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
Just poking around I was able to connect to the site and download it using a WebClient object

myWebClient.Credentials = new NetworkCredential("username", "password")
myWebClient.DownloadData("http://url");

That's pretty much useless for what I want to do though, which is open a new window that's already logged in/authenticated.
 

MrScott81

Golden Member
Aug 31, 2001
1,891
0
76
Can't you use the equivalent of PHP post variables in ASP? (POST instead of GET so they are not part of the URL).
 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
http://username:pass@url.com didn't work.

I've tried posting the values, but it doesn't seem to work - I don't control the code in the target sites, so I'm not entirely sure how they're managing logins.

Most of the sites I'm trying to log into are network webcams, if that helps anybody.
 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
Well, I've been able to login to the site, now I just need to figure out a way to open the authenticated page in a new window (or redirect the current window to the authenticated page, whichever way works)

The code thus far:

WebRequest request = ( WebRequest )WebRequest.Create ( resource);
CredentialCache cashe = new CredentialCache ( );

cashe.Add(new Uri("http://TargetIP"), "Basic", new NetworkCredential "user", "pass"));

request.Credentials = cashe;
HttpWebResponse response = ( HttpWebResponse )request.GetResponse ( );

Label1.Text = response.ResponseUri.ToString();

response.Close();


Any other advice/input?
 

imported_Dhaval00

Senior member
Jul 23, 2004
573
0
0
You can register a startup script (JavaScript) in your Page_Load that opens a new window on the client side.

The more easier would be to simply call Response.Redirect().
 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
Originally posted by: Dhaval00
You can register a startup script (JavaScript) in your Page_Load that opens a new window on the client side.

The more easier would be to simply call Response.Redirect().

That part is easy, but how do I pass it the login info? :)
 

hans007

Lifer
Feb 1, 2000
20,212
18
81
I dont know how to do it in c# but, you could set a cookie with that info, and then search for it with the other one.