Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Domain/MachineName$' being used for authentication instead of 'Domain/UserName'

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.

like image 914
Swastik Gupta Avatar asked Feb 21 '15 10:02

Swastik Gupta


2 Answers

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.

like image 180
Stephen Reindl Avatar answered Nov 14 '22 03:11

Stephen Reindl


I also encounter same problem in my intranet environment. The solution is simple yet hard to grab the idea. Usually, The IT Security In-charge will give you active directory service account to log in to your database. You can manage to log in with ssms but it fails in IIS because IIS choose to connect with domain/computername. So set custom account and fill in your domain/username and password.

  1. In IIS Manager, select the application pool that your web app uses or create a new one if you use the default one.
  2. Click on “Advanced Settings” in the right Actions bar. Under Process Model, click on the “Identity” value and select “Custom account”.
  3. Click on the “Edit” and enter domain/user name and password for user account.
  4. If you enter all information correctly, the pop-up will be closed successfully without any error messages.
  5. After that stop your Web Site.
  6. Back again to your application pool and click on the “Recycle”.
  7. Start your Web Site.

And that's it. you web application will successfully connect from IIS.

like image 29
phonemyatt Avatar answered Nov 14 '22 03:11

phonemyatt