{"id":932,"date":"2026-10-25T23:22:48","date_gmt":"2026-10-25T23:22:48","guid":{"rendered":"https:\/\/windows-vps.org\/blog\/?p=932"},"modified":"2026-10-25T23:22:48","modified_gmt":"2026-10-25T23:22:48","slug":"iis-application-pool-identity-sql-integrated-auth-errors","status":"publish","type":"post","link":"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/","title":{"rendered":"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You add integrated authentication to a connection string, and the site that worked with SQL logins on your workstation returns &#8220;Login failed for user &#8216;NT AUTHORITY\\SYSTEM'&#8221; on IIS. The mismatch is almost never in the connection string. It is between the Windows account the application pool runs as and the login that exists \u2014 or does not \u2014 inside SQL Server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Three different identities can be involved, and the one in the error is often not the one you expected. This guide checks each from the server and covers the permission problems that appear after authentication succeeds. <a href=\"https:\/\/windows-vps.org\/\">See the Windows VPS plans overview<\/a> for the baseline of a single-server IIS and SQL Server setup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Which identity your application pool actually uses<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An application pool runs under an identity defined on the pool, not the site. In IIS Manager, select the pool, open Advanced Settings, and look at <strong>Identity<\/strong>. The default is ApplicationPoolIdentity, a virtual account named after the pool \u2014 <code>IIS APPPOOL\\DefaultAppPool<\/code> \u2014 with no password and no interactive logon rights.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Older guides say to switch the pool to NetworkService or LocalSystem. Both work and both are far more privileged than necessary. NetworkService reaches SQL Server as <code>NT AUTHORITY\\NETWORK SERVICE<\/code>, LocalSystem as <code>NT AUTHORITY\\SYSTEM<\/code> \u2014 frequently a sysadmin on an Express install. Stay with ApplicationPoolIdentity; if you need a custom account, use a dedicated low-privilege user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reading the error message instead of guessing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;Login failed for user &#8216;NT AUTHORITY\\SYSTEM'&#8221; means SQL Server received the connection and rejected the principal \u2014 no such login, or no user mapped in the target database. &#8220;Login failed for user &#8221;. Reason: An attempt to log on using SQL Server Authentication failed&#8221; means no Windows token was sent, so the connection string still carries SQL credentials.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fixes are completely different. Check the connection string first: <code>Trusted_Connection=True;Integrated Security=SSPI;<\/code> with no <code>User ID<\/code> or <code>Password<\/code> keys. If a SQL credential is present, the Windows token is ignored entirely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the login for a virtual pool account<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The syntax looks odd because the name contains a backslash: the &#8220;server&#8221; is not the machine, it is literally <code>IIS APPPOOL<\/code>. Create the login in T-SQL rather than through the SSMS GUI, which mis-parses the name when you browse for it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- on the SQL Server instance, as a sysadmin\nCREATE LOGIN [IIS APPPOOL\\MyAppPool] FROM WINDOWS;\nUSE [MyDatabase];\nCREATE USER [IIS APPPOOL\\MyAppPool] FOR LOGIN [IIS APPPOOL\\MyAppPool];\nALTER ROLE [db_datareader] ADD MEMBER [IIS APPPOOL\\MyAppPool];\nALTER ROLE [db_datawriter] ADD MEMBER [IIS APPPOOL\\MyAppPool];\n\n-- custom local or domain account instead\nCREATE LOGIN [DOMAIN\\svc-webapp] FROM WINDOWS;\nGRANT CONNECT SQL TO [DOMAIN\\svc-webapp];<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Two mistakes follow. Creating the login but not the database user gives &#8220;The server principal is not able to access the database&#8221;. Granting <code>db_owner<\/code> because it removes the error is the other; a read-mostly app needs datareader, datawriter and execute, nothing more.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Symptom to cause: a quick lookup table<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Likely app pool identity<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Login failed for &#8216;NT AUTHORITY\\SYSTEM&#8217;<\/td><td>Pool set to LocalSystem (often the default for old installers)<\/td><td>Create login for <code>NT AUTHORITY\\SYSTEM<\/code> \u2014 or better, switch the pool back to ApplicationPoolIdentity<\/td><\/tr><tr><td>Login failed for &#8216;NT AUTHORITY\\NETWORK SERVICE&#8217;<\/td><td>Pool set to NetworkService<\/td><td>Create login for that principal, or use ApplicationPoolIdentity and grant it instead<\/td><\/tr><tr><td>Login failed for &#8216;IIS APPPOOL\\MyAppPool&#8217;<\/td><td>ApplicationPoolIdentity (correct default)<\/td><td><code>CREATE LOGIN FROM WINDOWS<\/code>, then create the database user and role<\/td><\/tr><tr><td>Cannot open database &#8220;X&#8221; requested by the login<\/td><td>Correct identity, no database user<\/td><td>Create the user <code>FOR LOGIN<\/code> inside the target database<\/td><\/tr><tr><td>Login failed for &#8221; \/ anonymous<\/td><td>None \u2014 connection string still has SQL creds<\/td><td>Remove User ID\/Password, add <code>Integrated Security=SSPI<\/code><\/td><\/tr><tr><td>Works in IIS Express, fails in IIS<\/td><td>Different identity in each host<\/td><td>Grant to the pool identity, not your developer account<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Use the table as a filter, then confirm with a query. <code>SELECT SUSER_NAME()<\/code> from a working connection names the principal your code runs under; <code>SELECT * FROM sys.server_principals<\/code> shows whether a matching login exists at all.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Confirming the identity from the server side<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Do not trust IIS Manager alone; the effective identity can be overridden in applicationHost.config. List the pool&#8217;s identity from an elevated prompt and compare. If someone edited the file by hand, the two disagree and the file wins after the next restart.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%windir%\\system32\\inetsrv\\appcmd list apppool \"MyAppPool\" \/text:processModel.identityType\n%windir%\\system32\\inetsrv\\appcmd list app \/text:applicationPool\nicacls \"C:\\inetpub\\wwwroot\\myapp\" \/grant \"IIS APPPOOL\\MyAppPool:(OI)(CI)RX\" \/T<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The second command is the one people forget. A site can have a perfectly configured pool that is not the pool serving the request, and no SQL Server change will fix that. Confirm the mapping first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Permissions after authentication: files, temp and double hop<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the login works, failures turn filesystem-bound. The pool identity needs read and execute on the app folder and modify rights on directories the app writes to \u2014 uploads, logs, App_Data. The <code>icacls<\/code> line above covers a read-only deployment; add <code>(OI)(CI)M<\/code> only on writable folders.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the app reaches SQL Server on another machine, you hit the double hop: the pool identity cannot be passed onward without Kerberos delegation. The symptom is a login failure for ANONYMOUS LOGON or a switch to the machine account. Register an SPN and configure constrained delegation, or use a SQL login for that one link.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A troubleshooting order that avoids wasted changes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Work in one direction and stop at the first thing that disagrees with expectations. First, reread the connection string for leftover credentials. Second, run <code>appcmd list app<\/code> to confirm which pool serves the request. Third, run <code>appcmd list apppool<\/code> to confirm that pool&#8217;s identity. Fourth, connect to SQL Server as a sysadmin and check <code>sys.server_principals<\/code> for the exact name from step three. Fifth, check <code>sys.database_principals<\/code> in the target database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Most reports are resolved at step four. Change one thing at a time \u2014 a full <code>iisreset<\/code> after every edit makes it impossible to tell which change fixed it, and a pool recycle is enough since identity is read when the worker starts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Integrated authentication is only mysterious when you skip the question of which identity is on the wire. Find the pool, confirm the mapping, create the login and user for that exact name, grant minimum roles, verify filesystem rights. That covers nearly every report. If you need a clean host to test the chain, <a href=\"https:\/\/windows-vps.org\/\">compare Windows VPS plans<\/a> with enough RAM for IIS and SQL Server together.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>You add integrated authentication to a connection string, and the site that worked with SQL logins on your workstation returns &#8220;Login failed for user &#8216;NT AUTHORITY\\SYSTEM&#8217;&#8221; on IIS. The mismatch is almost never in the connection string. It is between the Windows account the application pool runs as and the login that exists \u2014 or &#8230; <a title=\"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors\" class=\"read-more\" href=\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/\" aria-label=\"Read more about IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-932","post","type-post","status-publish","format-standard","hentry","category-reviews"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors - Windows VPS Blog<\/title>\n<meta name=\"description\" content=\"You add integrated authentication to a connection string, and the site that worked with SQL logins on your workstation returns &quot;Login failed for user &#039;NT\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors\" \/>\n<meta property=\"og:description\" content=\"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors\" \/>\n<meta property=\"og:url\" content=\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/\" \/>\n<meta property=\"og:site_name\" content=\"Windows VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-25T23:22:48+00:00\" \/>\n<meta name=\"author\" content=\"windows-vps\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@myxiechengxuan\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"windows-vps\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/\",\"url\":\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/\",\"name\":\"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors - Windows VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\"},\"datePublished\":\"2026-10-25T23:22:48+00:00\",\"author\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\"},\"description\":\"You add integrated authentication to a connection string, and the site that worked with SQL logins on your workstation returns \\\"Login failed for user 'NT\",\"breadcrumb\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/windows-vps.org\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\",\"url\":\"https:\/\/windows-vps.org\/blog\/\",\"name\":\"Windows VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/windows-vps.org\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\",\"name\":\"windows-vps\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"caption\":\"windows-vps\"},\"sameAs\":[\"https:\/\/windows-vps.org\/blog\",\"https:\/\/x.com\/myxiechengxuan\"],\"url\":\"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors - Windows VPS Blog","description":"You add integrated authentication to a connection string, and the site that worked with SQL logins on your workstation returns \"Login failed for user 'NT","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/","og_locale":"en_US","og_type":"article","og_title":"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors","og_description":"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors","og_url":"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/","og_site_name":"Windows VPS Blog","article_published_time":"2026-10-25T23:22:48+00:00","author":"windows-vps","twitter_card":"summary_large_image","twitter_creator":"@myxiechengxuan","twitter_misc":{"Written by":"windows-vps","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/","url":"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/","name":"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors - Windows VPS Blog","isPartOf":{"@id":"https:\/\/windows-vps.org\/blog\/#website"},"datePublished":"2026-10-25T23:22:48+00:00","author":{"@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58"},"description":"You add integrated authentication to a connection string, and the site that worked with SQL logins on your workstation returns \"Login failed for user 'NT","breadcrumb":{"@id":"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/windows-vps.org\/blog\/iis-application-pool-identity-sql-integrated-auth-errors\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/windows-vps.org\/blog\/"},{"@type":"ListItem","position":2,"name":"IIS Application Pool Identities and SQL Server Integrated Auth: Fixing the Login Failed Errors"}]},{"@type":"WebSite","@id":"https:\/\/windows-vps.org\/blog\/#website","url":"https:\/\/windows-vps.org\/blog\/","name":"Windows VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/windows-vps.org\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58","name":"windows-vps","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","caption":"windows-vps"},"sameAs":["https:\/\/windows-vps.org\/blog","https:\/\/x.com\/myxiechengxuan"],"url":"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/"}]}},"_links":{"self":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/comments?post=932"}],"version-history":[{"count":1,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/932\/revisions"}],"predecessor-version":[{"id":940,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/932\/revisions\/940"}],"wp:attachment":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/media?parent=932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/categories?post=932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/tags?post=932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}