I recently spent three days trying to solve the same problem, and it drove me crazy. This happened during a load-balanced installation, where one of the servers authenticated correctly and the other failed. Examining the problem - and finally resolving it - it turned out that it is not connected with a load-balanced environment, it can happen to any server during authentication using Windows authentication, and the server is called with a name different from the name recognized by Active Directory
1. Enable Kerberos Logging
To properly diagnose your problem, you need to enable Kerberos logging on the computer hosting your IIS site. To do this, add the following registry entry:
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ LSA \ Kerberos \ Parameters
Add a LogLevel registry value with ValueType REG_DWORD and a value of 0x1 .
As soon as you turn on logging, you try to authenticate, you get errors that are logged in your Windows application log. You can ignore the KDC_ERR_PREAUTH_REQUIRED error (this is only part of the handshake), but if you get the KDC_ERR_C_PRINCIPAL_UNKNOWN error message , it means that your AD controller does not recognize your server, so you need to follow these steps.
2. KDC_ERR_C_PRINCIPAL_UNKNOWN
if you get KDC_ERR_C_PRINCIPAL_UNKNOWN, it means that the name "mysite.mydomain.com" is different from how AD recognizes your computer so that it cannot provide a valid ticket in the keberos. In this case, you need to register the service principal name (SPN) for "www.mysite.mydomain" in AD.
Run this command on the AD controller - you will need the domain administrator privilege:
Setspn -A HTTP/mysite.mydomain YOUR_MACHINE_HOSTNAME
3. Use an individual identifier for the application pool
Finally, make the application pool use a custom account owned by Active Directory instead of using NetworkService. This can be done in the advanced settings of your application pool.
and .. voila.
Notes. The problem may (unlikely) be due to the fact that several SPNs are registered on the same computer, in which case you will need to run a command to remove duplicate SPNs, but I doubt it is. Also try adding another binding to your site (which does not use a user name), for example htttp: // localhost: custom_port_number, and see if authentication works. If this works, itβs another sign that you are suffering from the same problem as me.