I have an SDK that allows me to integrate project with other system.
This SDK offers a class called WindowsAuthSettings()
. This class supposed to obtain my windows authentication and pass them to the server to start a communication session between my application and the external services.
However, the external service keep telling me the "User name and/or password is invalid."
When I dump WindowsAuthSettings()
to the screen as a json object, I found out that my this class is obtaining the pool name as the username IIS APPPOOL\\MvcApp
instead of my username.
To make sure it is not something wrong with my setup, I created a standard Microsoft ASP.NET MVC 5 project with "Windows Authentication".
Then I added the following method to my HomeController
public JsonResult Test()
{
return Json(
new
{
All = new WindowsAuthSettings(),
Kerberos = new WindowsAuthSettings(WindowsAuthProtocols.Kerberos),
Ntlm = new WindowsAuthSettings(WindowsAuthProtocols.Ntlm),
}, JsonRequestBehavior.AllowGet);
}
I published my project to my web server. Then I disabled the "Anonymous Authentication" and enabled "Windows Authentication" like this
Now when I go to http://example.domain.com/MvcApp/Home/Test I get the following output.
On the upper right hand-side on my layout I get the correct logged in username DOMAIN\username
but the WindowsAuthSetting()
class is not returning the correct credentials.
According the the documentation I should enable use Impersonation with Windows Authentication by adding the following to my config file
<system.web>
...
<authentication mode="Windows"/>
<identity impersonate="true"/>
...
</system.web>
However, when the line <identity impersonate="true"/>
is added, I get HTTP 500 Internal Server Error.
What other setting do I need to do in order for IIS to give my app the correct credentials?