ralphtrent
Programmer
I have an ASP.net 3.5 app that will attempt to connect to an internal webpage to make sure it is accepting request.
I need to pass a user id because this process is a service and the user running the service may not have access to that page if Windows Authenication is being used.
I have the following code which takes a user account (domain\id and password) from a database, creates a NetworkCredential object sets the HttpRequest.Credentials to this new object. The problem is i never fail even when I pass-in an invalid user account.
If feels like its use the default creds no matter what I do.
Any help is appreciated.
I need to pass a user id because this process is a service and the user running the service may not have access to that page if Windows Authenication is being used.
I have the following code which takes a user account (domain\id and password) from a database, creates a NetworkCredential object sets the HttpRequest.Credentials to this new object. The problem is i never fail even when I pass-in an invalid user account.
Code:
HttpWebRequest lwhwrWebRequestObject;
lwhwrWebRequestObject = (HttpWebRequest)HttpWebRequest.Create(lstrURL);
NetworkCredential nc = new NetworkCredential(lstrCredUserName, lstrCredPassword, lstrCredDomain);
CredentialCache cc = new CredentialCache();
cc.Add(new System.Uri(lstrURL), "Basic", nc);
lwhwrWebRequestObject.Credentials = cc;
lwhwrWebRequestObject.GetResponse(); // Returns successfully everytime. I would expect an error if the account is not correct.
If feels like its use the default creds no matter what I do.
Any help is appreciated.