C# – ‘Domain/MachineName$’ being used for authentication instead of ‘Domain/UserName’

asp.netauthenticationciis-7sql server

The following post may look same but I was unable to correct the problem after attempting all the solutions provided as answers.
(Login failed for user 'DOMAIN\MACHINENAME$')

MY PROBLEM

I am deploying a asp.net web-app with forms authentication enabled on my IIS7 dev server in a Windows Network. My SQL Server is deployed on a remote box, in the same network, with necessary TCP ports opened for remote connections. All the domain users have been given access to necessary databases in SQL server.

Now when I try to run my web-app, following error comes up:

Login failed for user 'DOMAIN\MachineName$'.

I have already given adequate permissions to NT AUTHORITY\NETWORK SERVICE in my SQL server.

I don't want to give any permission to 'DOMAIN\MachineName$' in the SQL server as the developers keep changing the machine names for various test purposes.

The connecting string I am using is:

"Server=SQL-SERVER;Initial Catalog=MyDatabase;Integrated Security=SSPI;Persist Security Info=False"

SQL Provider is System.Data.SqlClient

Anonymous and Form authentication are enabled as my web-app contains login.aspx.

Best Answer

The point is that whenever you use NT AUTHORITY\NETWORK SERVICE as your application pool user, the system translates this in the network to DOMAIN\MachineName$.

What we do is to use the user name of the developer to connect to the machine by setting the username of the application pool to the developer's name.