Tuesday, September 4, 2007

Windows Authentication in ASP.NET 2.0

In ASP.NET 2.0 Development environment while connecting
with SQL server 2005 you will be always using SQL Server

authentication. For Internet applications SQL Server authentication is advisable, but for Intranet applications you need to use

Windows Authentication.

Lets see how to adapt that:

1. Go to your SQL Server 2005
2. Search for Security (will be lying below)
3. Inside search for Logins
4. Add New-->>Login name:
5. Login name should be your NT user name
6. After adding the user name (for ex: if you have added Mike as a new user), then select Mike, right click properties & reach properties and go to server roles & select sysadmin and click OK.
7. Before clicking OK button ensure you have selected the appropriate required DB.

In Web.config change the connection string , that is remove the user name, password and make Integrated Security as true.

Sample :


add value="Data Source=Your SQL Server 2005;Initial Catalog=DBName; Integrated Security=True" key="MyConnection"

Your SQL Server 2005-- Can be in your machine(put then localhost) (OR) in a different network then put address of SQL

Server 2005 (like 10.10.10.10 (for example)) there. 'key' value refers to the connection string name to be used across .aspx

pages.

Thats it!!! Windows authentication in ASP.NET 2.0

For assistance, feel free to email @ sharpeye500 at yahoo dot com

No comments: