Ask a Question related to ASP.NET Security, Design and Development.
-
Stan Rawrysz #1
Credentials persist after CredentialCache.Remove()
So I've been banging my head against the wall here for a while now and
cannot find any useful information regarding this issue that I'm having.
The problem is that after I create a WebRequest object with a
CredentialCache and make a call to the resource, all subsequent requests
to that resource, even if I don't set the cache to the next WebRequest
and set the cache to null, end up using that NetworkCredential from the
original request.
I've setup a quick unit test to expose this problem:
[Test]
[Explicit]
[ExpectedException(typeof
(WebException))]
public void CredentialCachePersistenceTest()
{
Stream myStream = null;
Uri myAuthTestUri = new Uri(_authTestUrl);
NetworkCredential myCred = new NetworkCredential(_authTestUser,
_authTestPass, _authTestDomain);
CredentialCache myCache = new CredentialCache();
myCache.Add(myAuthTestUri, "Basic", myCred);
WebRequest myReq = WebRequest.Create(myAuthTestUri);
myReq.Credentials = myCache;
WebResponse myResponse = myReq.GetResponse();
myStream = myResponse.GetResponseStream();
Console.WriteLine("Stream1.CanRead = " + myStream.CanRead);
myStream.Close();
myCache.Remove(myAuthTestUri, "Basic");
myResponse.Close();
myCache = null;
WebRequest myReq2 = WebRequest.Create(new Uri(_authTestUrl));
WebResponse myResponse2 = myReq2.GetResponse();
myStream = myResponse2.GetResponseStream();
Console.WriteLine("Stream2.CanRead = " + myStream.CanRead);
}
The web site I'm connecting to is set to have anonymous access off with
"Basic Authentication" and "Integrated Windows Security" on.
Has anyone come accross this problem? Is there a solution?
Stan Rawrysz Guest
-
CredentialCache.DefaultCredentials not working!!!!!
Hi, I'm trying to use the CredentialCache.DefaultCredentials to pick up the credentials of the current user but its not working correctly. I've... -
CredentialCache.DefaultCredentials Not working
I am using the following method to call a web service from a windows application Dim a As New MachineReference.Service1 a.Credentials = s... -
How to CHANGE the Credentials for a web service proxy when using CredentialCache ?
Hi I'm trying to invoke a Web Service which is using BASIC authentication. Code for invoking: CredentialCache cc = new CredentialCache();... -
net.credentialcache.defaultcredentials is blank and will not retain user info
Hi, As the subject suggests, the defaultcredentials object that i need my code to acces is empty, despite the user having logged onto a win 2000... -
authentication using CredentialCache against proxy server problem
Hi all I'm not able to authenticate against proxy server when I try to pass an instance of CredentialCache to WebProxy instance used with...



Reply With Quote

