Introduction
At times, Windows Authentication in Microsoft SQL Server is not enough. One of the requirements is in ASP.Net as
described in the FAQ here.
This article descibes how to setup mixed mode authentication, also known as SQL Authentication, in Microsoft SQL Server 2000, 2005 and 2005 Express Edition.
Now of course, the need does not arise if the care is taken during installation of SQL Server 2000 and 2005. But for
SQL Server 2005, it becomes mandatory. We explore all versions anyway.
Mixed Mode Authentication for SQL Server 2000
Launch Enterprise Manager for SQL Server 2000. Browse to the server node that you are interested in as shown below.
Right click and select the option Properties or from the Action menu, select Properties.
Go to the Security tab and select SQL Server and Windows option for Authentication.
You may need to restart the server.
Mixed Mode Authentication for SQL Server 2005 Express Edition
For SQL Server 2005 Express Edition, there is not GUI tool available to configure the server. You need to go it manually.
The first step is to change the login-mode.
Open registry editor (launch application %WINDIR%\regedit.exe) and go to
HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer in the tree on the left.
On the right, look for an entry named LoginMode. The default value, when installed is 1.
Update it to 2. The next step is to restart the service.
Launch your Service Manager (Start -> Run -> Type services.msc)
and look for a service named MSSQL Server (SQLEXPRESS). Restart the service.
Hey! We are not done yet... at least practically. We need to add a user with administrative priviledges
so that the database can be accessed from ASP.Net.
On the command prompt, login to SQL Server command prompt using the osql utility. SQL Server 2005
Express Edition is installed with the instance name SQLEXPRESS. Use the following command to login:
osql -E -S .\SQLEXPRESS
One the SQL-command prompt, execute the following?
1> exec sp_addlogin 'username', 'password'
2> go
1> exec sp_addsrvrolemember 'username', 'sysadmin'
2> go
1> quit
Replace the username and password but not forget the quotes.
To verify, try login using the following on the command prompt:
osql -S .\SQLExpress -U username
Provide the password when asked for and you should be through!
Mixed Mode Authentication for SQL Server 2000
Launch SQL Server Management Studio. Connect using Windows Authentication. Ensure that you are logged in
as with administrative privileges. On the machine node in Object Explorer,
right click and select option Properties.
Go to the Security page and select SQL Server and Windows Authentication Mode
for the Server Authentication.
You may need to restart the server.
Conclusion
For Microsoft SQL Server 2000 and 2005, having initial wrong choice for authentication is, now, not a burden.
Also, for Microsoft SQL Server 2005 Express Edition, it is easy to configure it for the mixed mode
authentication and create new IDs.