|
Home > Archive > Microsoft Content Management Server > July 2006 > HttpWebRequest to download a posting
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
HttpWebRequest to download a posting
|
|
| Martin Rojo 2006-07-20, 7:17 pm |
| Our CMS web site has a feature whereby we can bundle documents into a ZIP
file and download the zip file.
ALthough Chester's blog suggests Using HttpWebRequest with
NetworkCredentials the web request continually is redirected to the domain's
login page. THis is ASP .NET and the user is already authenticated -- using
Forms authentication with Stefans SimpleMCMSSiteMapProvider.
Here's a code snippet, do you spot anything wrong?
I've already tried copying the cookies over from HttpContext.Current to the
new HttpWebRequest , but that's rejected as well.
Advice is appreciated.
where sURL is the URL of the document
HttpWebRequest xWR = (HttpWebRequest)HttpWebRequest.Create(sURL);
NetworkCredential xNC = new NetworkCredential("Winnt://<user>",
"password", "domain");
xWR.Credentials = xNC;
xWR.Method = "GET";
xWR.UserAgent = "Mozilla/4.0+";
HttpWebResponse WResponse = (HttpWebResponse)xWR.GetResponse();
MCMS is managing security and the credentials are valid (good login and
password).
No errors are returned, but the credentials aren't accepted and the response
is that of the login page --
| |
| Stefan [MSFT] 2006-07-21, 7:21 am |
| Hi Martin,
in my code I always pass in the username to network credentials without
"WinNT://"
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"Martin Rojo" <MartinRojo@discussions.microsoft.com> wrote in message
news:CE3E3954-CAB9-4D9F-9A38-EB30B5683D5A@microsoft.com...
> Our CMS web site has a feature whereby we can bundle documents into a ZIP
> file and download the zip file.
>
> ALthough Chester's blog suggests Using HttpWebRequest with
> NetworkCredentials the web request continually is redirected to the
> domain's
> login page. THis is ASP .NET and the user is already authenticated --
> using
> Forms authentication with Stefans SimpleMCMSSiteMapProvider.
>
> Here's a code snippet, do you spot anything wrong?
>
> I've already tried copying the cookies over from HttpContext.Current to
> the
> new HttpWebRequest , but that's rejected as well.
>
> Advice is appreciated.
>
> where sURL is the URL of the document
>
> HttpWebRequest xWR = (HttpWebRequest)HttpWebRequest.Create(sURL);
> NetworkCredential xNC = new NetworkCredential("Winnt://<user>",
> "password", "domain");
>
> xWR.Credentials = xNC;
> xWR.Method = "GET";
> xWR.UserAgent = "Mozilla/4.0+";
> HttpWebResponse WResponse = (HttpWebResponse)xWR.GetResponse();
>
> MCMS is managing security and the credentials are valid (good login and
> password).
>
> No errors are returned, but the credentials aren't accepted and the
> response
> is that of the login page --
>
| |
| Martin Rojo 2006-07-21, 1:17 pm |
| Dear Stefan,
thanks for your reply, actually I tried multiple combinations of domain and
login , including or not "WinNT://"
still no joy.
But at least it should work right?, so its likely the domain.
Sincerely,
Martin
"Stefan [MSFT]" wrote:
> Hi Martin,
>
> in my code I always pass in the username to network credentials without
> "WinNT://"
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> Check out the new book as well: Advanced MCMS development:
> http://tinyurl.com/8ugwj
> ----------------------
>
>
> "Martin Rojo" <MartinRojo@discussions.microsoft.com> wrote in message
> news:CE3E3954-CAB9-4D9F-9A38-EB30B5683D5A@microsoft.com...
>
>
>
| |
| Stefan [MSFT] 2006-07-24, 7:23 am |
| Hi Martin,
you need to specify only user, password and domain.
If your user is "CMSUser", your password is "MyPassword" and your domain is
"MyDomain" you would need to call it like this:
NetworkCredential credentials = new NetworkCredential("CMSUser",
"MyPassword", "MyDomain");
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"Martin Rojo" <MartinRojo@discussions.microsoft.com> wrote in message
news:AE314355-7D70-4011-80E0-F90443AD17C6@microsoft.com...[vbcol=seagreen]
> Dear Stefan,
>
> thanks for your reply, actually I tried multiple combinations of domain
> and
> login , including or not "WinNT://"
> still no joy.
> But at least it should work right?, so its likely the domain.
>
> Sincerely,
>
> Martin
>
> "Stefan [MSFT]" wrote:
>
| |
| Martin Rojo 2006-07-24, 1:20 pm |
| Dear Stefan,
the domain was a red-herring,
NetworkCredentials don't work with Forms authentication right?
our CMS install is using forms authentication.
so actually the cookies had to be reverse engineered (messy)
the basic idea and source is here, FWIW
http://odetocode.com/Articles/162.aspx
Thanks for your reply,
-- marteen
"Stefan [MSFT]" wrote:
> Hi Martin,
>
> you need to specify only user, password and domain.
> If your user is "CMSUser", your password is "MyPassword" and your domain is
> "MyDomain" you would need to call it like this:
>
> NetworkCredential credentials = new NetworkCredential("CMSUser",
> "MyPassword", "MyDomain");
>
> Cheers,
> Stefan
>
>
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> Check out the new book as well: Advanced MCMS development:
> http://tinyurl.com/8ugwj
> ----------------------
>
>
> "Martin Rojo" <MartinRojo@discussions.microsoft.com> wrote in message
> news:AE314355-7D70-4011-80E0-F90443AD17C6@microsoft.com...
>
>
>
| |
| Stefan [MSFT] 2006-07-25, 7:39 am |
| Hi Martin,
you are correct: network credentials only work when the website supports
windows authentication.
What you could do is to setup a second website which is configured for
windows auth for this specific usage.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"Martin Rojo" <MartinRojo@discussions.microsoft.com> wrote in message
news:C4323EED-825C-436D-9E80-FD260601B8C1@microsoft.com...[vbcol=seagreen]
> Dear Stefan,
>
> the domain was a red-herring,
> NetworkCredentials don't work with Forms authentication right?
> our CMS install is using forms authentication.
>
> so actually the cookies had to be reverse engineered (messy)
>
> the basic idea and source is here, FWIW
>
> http://odetocode.com/Articles/162.aspx
>
> Thanks for your reply,
>
> -- marteen
>
>
> "Stefan [MSFT]" wrote:
>
|
|
|
|
|