I have 2 Windows 2008 Servers. One is a web server (IIS7). The other is a database server (SQL Server 2008). The instance of sql server 2008 is configured to use mixed mode authentication. Neither are joined to an active directory domain.

How should ASP.NET applications on the web server login to the databases on the database server? I have tested with the SA account, but obviously I need to change that.

I am confused about what to use: sql server account, windows accounts configured on each machine, or "Application Roles," which I don't really have a great understanding of.

The account just needs to be able to read and write data, and execute stored procedures. What should I do and how do I set it up?


Instead of just a quick answer, please give me instructions on how to set this up. Thanks.


The more secure method uses Windows authentication. This will allow you to write your application without a password included in any of the connection strings or config file.

One each system you will create a user account. This should not be an administrator account, just a regular user account. One both systems create the user with the same name and password.

Now on your IIS system edit the application pool settings. Change the identity to run as the user account that you just created. At this point you will need to type in the password for the user.

On the SQL server create a login account that is associated with the Windows use account that you have created. You can use the normal SQL Server permissions to grant/deny the actions that your application requires.

Now in your application connect to the SQL server using integrated security. The app pool user will be used when making the SQL connection.

No password in your config or app and a secure database connection!

| improve this answer | |

The most common method to use would be a SQL Login. Create a SQL Login with a strong password. Add it as a user to the database your application will be using. Create a database role in the database and make your user a member of this role. Grant the database role access to the objects that it needs access to.

You'll want to only grant the role the rights that it needs.

The reason for the database role is so that you can restore the database to another server and be able to easily grant the exact rights to another user so that you can ensure that everything is working correctly.

| improve this answer | |
  • Why not NT auth? – Sam Jul 8 '09 at 22:45
  • 1
    Windows auth is preferred in a domain. In a workgroup it gets harder to setup and ensure that its working correctly as you have to manually keep the passwords between the machines in sync. – mrdenny Jul 8 '09 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.