Home > Archive > C# > June 2004 > NetworkCredentials not working
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 |
NetworkCredentials not working
|
|
| Greg Ellis 2004-04-08, 4:35 pm |
| I am trying to access a page using a WebRequest.
I know it needs the proper credentials so I set it up as follows:
string cszServerName = Page.Request.ServerVariables.Get("SERVER_NAME");
Uri baseUri = new Uri("http://"+cszServerName);
Uri myUri = new Uri(baseUri, filepath,false);
WebRequest objRequest = WebRequest.Create(myUri);
string cszUserName =
clsCookieLib.GetTripleDESEncryptedCookieValue("UserName");
string cszPassword =
clsCookieLib.GetTripleDESEncryptedCookieValue("Password");
NetworkCredential credentials = new NetworkCredential(cszUserName,
cszPassword, "axia");
objRequest.Credentials = credentials;
WebResponse objResponse = objRequest.GetResponse(); <----- 401 error is
produced on this line!!!
However, I still get a 401 Unauthorized access error on this line
WebResponse objResponse = objRequest.GetResponse();
I know that my credentials are correct because I typed them in the dialog
box that comes up when you try to access the page through Internet Explorer
and everything came up fine.
Anyone know what I am doing wrong or if this is a huge bug in .NET?
Thanks,
Greg
| |
| Feroze [MSFT] 2004-06-03, 7:31 pm |
| What kind of server and authentication scheme are you using ?
Are you sure that "clsCookie.GetTripleDESEncodedCookieValue(...)" is
returning the correct username & password ?
--
feroze
http://weblogs.asp.net/feroze_daud
============
Remove "user" from the email address to reply to the author.
This posting is provided "AS IS" with no warranties, and confers no rights
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Greg Ellis" <nothing@nospam.com> wrote in message
news:b6idc.23605$J56.17911@edtnps89...
> I am trying to access a page using a WebRequest.
>
> I know it needs the proper credentials so I set it up as follows:
> string cszServerName = Page.Request.ServerVariables.Get("SERVER_NAME");
> Uri baseUri = new Uri("http://"+cszServerName);
> Uri myUri = new Uri(baseUri, filepath,false);
> WebRequest objRequest = WebRequest.Create(myUri);
>
> string cszUserName =
> clsCookieLib.GetTripleDESEncryptedCookieValue("UserName");
> string cszPassword =
> clsCookieLib.GetTripleDESEncryptedCookieValue("Password");
> NetworkCredential credentials = new NetworkCredential(cszUserName,
> cszPassword, "axia");
> objRequest.Credentials = credentials;
> WebResponse objResponse = objRequest.GetResponse(); <----- 401 error is
> produced on this line!!!
>
>
> However, I still get a 401 Unauthorized access error on this line
> WebResponse objResponse = objRequest.GetResponse();
> I know that my credentials are correct because I typed them in the dialog
> box that comes up when you try to access the page through Internet
Explorer
> and everything came up fine.
>
> Anyone know what I am doing wrong or if this is a huge bug in .NET?
>
> Thanks,
> Greg
>
>
|
|
|
|
|