2

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

enter image description here

Now when I go to http://example.domain.com/MvcApp/Home/Test I get the following output.

enter image description here

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?

Junior
  • 11,602
  • 27
  • 106
  • 212
  • I think you were on the right path with the impersonate users, however, when you do that, your entire web app runs in the context of that user. If the group/user(s) that you are impersonating do not have read access to your web app's folder, IIS will toss the 500 error as it can't access the folder of the web app. Is this a domain setup? You should be able to give "Authenticated Users" in your domain read only access to the web app folder and test if that solves the 500 error. – Tommy Nov 01 '17 at 01:02
  • Use `Controller.User`. – Lex Li Nov 01 '17 at 01:16

0 Answers0