The credentials supplied to the package were not recognized

I am using ravendb as database in my current project and got tired of the following exception when running the database and the web site on the same machine:


The credentials supplied to the package were not recognized

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ComponentModel.Win32Exception: The credentials supplied to the package were not recognized


[Win32Exception (0x80004005): The credentials supplied to the package were not 
   recognized]
   System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob,
   Boolean throwOnError, SecurityStatus& statusCode) +7737075
   System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob) +91
   System.Net.NegotiateClient.DoAuthenticate(String challenge, WebRequest
   webRequest, ICredentials credentials, Boolean preAuthenticate) +7856776
   System.Net.NegotiateClient.Authenticate(String challenge, WebRequest webRequest,
   ICredentials credentials) +18
   System.Net.AuthenticationManager.Authenticate(String challenge, WebRequest
   request, ICredentials credentials) +149
   System.Net.AuthenticationState.AttemptAuthenticate(HttpWebRequest httpWebRequest,
   ICredentials authInfo) +7856166
   System.Net.HttpWebRequest.CheckResubmitForAuth() +7859430
   System.Net.HttpWebRequest.CheckResubmit(Exception& e) +126 
  
This happens because I've configured raven to prevent anonymous access and to accept windows authentication. My connection string looked like: 
"Url = http://localhost:8080; User=sam; Password=pass"
The windows authentication works well when the database is on remote server. But unfortunately when the site and the database are running on the same machine, IIS prevents it to get working for a safety precaution.

To get out of this problem, I found a work around from web that says to disable the loopback check. The details about how to do that can be found in here.

But this didn't work for me and finally what I got to resolve this problem after spending a whole day is to remove the username and password from the connection string. 

It might be the reason that the web site was already authenticated using integrated authentication, but this is wired because the credentials were correct!

 

Comments

Post a Comment

Popular posts from this blog

Adding security headers to prevent XSS and MiTM attacks in .Net Core

Creating transformations for custom config files

Microsoft.IdentityModel.Protocols.OpenIdConnectProtocolInvalidNonceException