C# – credentialcache.defaultcredentials returning wrong user credentials

asp.netauthenticationcweb services

I have a ASP.NET Website (.NET 2 IIS 5.1) running on machine A with Integrated Windows Authentication enabled. It has a user Automation.
When I connect to it from machine B with user 'Ganesh', I am prompted to enter username & password (by IE itself).

CASE 1:
If I DONT save the credentials using remember my password option:
I get connected to the website.However later internally I need to connect to a webservice to get some details (via code). To to that, the code first sets the credentials to default credentials.

statusService.Credentials = CredentialCache.DefaultCredentials;

Now here the logged in user 'Ganesh' credentials are passed for some reason. (I found that using logon audits logging at the server)

Hence when I call the service:

m_LicenseStatus = statusService.GetLicenseStatus(out m_dNoEvalDays);

I get HTTP 401 Unauthorized exception.

CASE 2:
If I save the credentials using remember my password option:

'Automation' user credentials are passed & the call is successful.

Hence my question is why do I need to save the credentials? It is a necessity or have I missed something?

Best Answer

I contacted Microsoft about this issue.

Following were the recommendations:

http://blogs.msdn.com/jpsanders/archive/2009/09/03/using-httpwebrequest-with-credential-manager.aspx I opted for a note to be included in known issues list of my software. Hope this helps.

Related Topic