title: Login failed for user IIS APPPOOL\WebExploit
body: <p>I use Windows Authentication against Active Directory in my ASP.NET MVC website. I am now trying to deploy the site to test, but the problem is that I keep getting the following exception at login:</p>
  <blockquote>
  <p>Cannot open database &quot;PrincipalServerDB&quot; requested by the login. The login failed.
  Login failed for user 'IIS APPPOOL\WebExploit'.</p>
  </blockquote>
  <p>I have followed this tutorial to deploy to test : <a href="https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis</a></p>
  <p>And I use authentication as described here :
  <a href="http://tech.trailmax.info/2016/03/using-owin-and-active-directory-to-authenticate-users-in-asp-net-mvc-5-application/" rel="nofollow noreferrer">http://tech.trailmax.info/2016/03/using-owin-and-active-directory-to-authenticate-users-in-asp-net-mvc-5-application/</a>
  that uses OWIN authentication.</p>
  <p>I am conscious that my question lacks understanding, but it is because I don't understand what's going on . I have tried following the steps as described in this post <a href="https://stackoverflow.com/a/7698316/4714502">https://stackoverflow.com/a/7698316/4714502</a> but I had already done a <code>Grant.sql</code> script to grant access as follows :</p>
  <pre><code>    IF NOT EXISTS (SELECT name FROM sys.server_principals WHERE name = 'IIS APPPOOL\DefaultAppPool')
  BEGIN
      CREATE LOGIN [IIS APPPOOL\DefaultAppPool] 
        FROM WINDOWS WITH DEFAULT_DATABASE=[master], 
        DEFAULT_LANGUAGE=[us_english]
      END
      GO
      CREATE USER [WebExploitUser] 
        FOR LOGIN [IIS APPPOOL\DefaultAppPool]
      GO
      EXEC sp_addrolemember 'db_owner', 'WebExploitUser'
      GO
  </code></pre>
  <p>In the first tutorial they say :</p>
  <blockquote>
  <p>When the application runs in IIS on your development computer, the application accesses the database by using the default application pool's credentials. However, by default, the application pool identity does not have permission to open the databases. So you have to run a script to grant that permission. In this section you create the script that you'll run later to make sure that the application can open the databases when it runs in IIS.</p>
  </blockquote>
  <p>That means it's the application that has the rights right? Not the actual user?
  Don't know how to solve this...</p>
  <p>If I look into SSMS, in my PrincipalServerDB properties, authorizations show <code>WebExploitUser</code> as defined.</p>
  <p>Here is my Application Pool in IIS:</p>
  <p><a href="https://i.stack.imgur.com/0vl2X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0vl2X.png" alt="enter image description here" /></a></p>
  <p>'Démarré' means started in French.</p>