IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Resolve Login failed for user ‘DOMAIN\PCNAME$’

When migrating ASP.NET applications from Windows Server 2003 (IIS 6) to 2012 R2 (IIS 8.5), right away, one web application displayed the yellow screen of death with the following error message:

System.Data.SqlClient.SqlException: Login failed for user ‘DOMAIN\SERVERNAME$‘.

If your application is on a private network, depending on your situation, there is a few approaches you can take.

Options

  1. Grant DOMAIN\SERVERNAME$ user id read and write to the SQL Server database. Application pool needs to run under the identity of NetworkService.

    So now the question is how do you add DOMAIN\SERVERNAME$ username as a new login in SQL Server? This may be obvious to many of you, but it tripped a few people including some DBAs here. The key is just to type the DOMAIN\SERVERNAME$ in the Login name: text box without searching it. Click OK button right away. Then you should be able to do the rest to add the roles, etc to the new login.

    SSMS New Login DOMAIN\SERVERNAME$

  2. Change Application Pool Identity to use custom account and have it run under a network service account. Bear in mind, the service account also needs to have access in SQL Server.

  3. Create an SQL Server login and make sure the connectionStrings in the application’s web.config use User Id and Password instead of using integrated security.

    Before

    <connectionStrings>
      <add name="MyConnection" connectionString="Data Source=SERVER;Initial Catalog=ITNOTADB;Integrated Security=SSPI" />
    </connectionStrings>   
    

    After

     
    <connectionStrings>
      <add name="MyConnection" connectionString="Data Source=SERVER;Database=ITNOTADB;User ID=ITNOTA;Password=Pa$$w0rd" />
    </connectionStrings>
    

    The keywords Initial Catalog and Database can be used interchangeably.

After some considerations, we opted for the third option with the acknowledgement that while it was not the best option, it was the quickest to do to resolve the issue.

Further Reading

Error message when you specify configuration database settings on the Set Configuration Database Server page in SharePoint Administration: “Error 18456”
Understanding Kerberos and NTLM authentication in SQL Server Connections
Application Pool Identities
Is using integrated security (SSPI) for accessing SQL Server better for web applications?
Professional Microsoft IIS 8

March 24, 2015 Filed Under: How To Tagged With: ASP.NET, IIS, Internet Information Services, Windows Server

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure