Is there a way to change the authorization mode in SQL Server 2008 or 2012 without using the SQL Server Management Studio?
In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties. On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
2.3 Enabling SQL Authentication or Mixed AuthenticationRight-click the server you wish to modify and then click Properties. Select the Security Page. Under the Server authentication heading choose either the desired authentication: Windows Authentication or SQL Server and Windows Authentication mode. Click OK.
SQL Server supports two authentication modes, Windows authentication mode and mixed mode. Windows authentication is the default, and is often referred to as integrated security because this SQL Server security model is tightly integrated with Windows.
In SQL Server Management Studio Object Explorer, right-click on the server name, click Properties and go to Security page to check the SQL Server Authentication. In this case we can see that it is Windows Authentication mode.
In Object Explorer, open Security folder, open Logins folder. Right click on the local account and go to Properties. In the Login Properties window, select the Status tab. Set Login to Disabled, or set Permission to connect to database engine to Deny.
Here is what Management Studio does to change the authentication mode from mixed to Windows only:
EXEC xp_instance_regwrite
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode',
REG_DWORD,
1;
And from Windows only back to mixed:
EXEC xp_instance_regwrite
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode',
REG_DWORD,
2; -- only difference is right here
You can call the same command from various sources that can connect to SQL Server such as SQLCMD, PowerShell, VBScript, C#, etc. Or you can log directly onto the server, navigate to that registry key, and change the value manually (as @marc_s suggested).
Note that in all cases you have to restart SQL Server in order for the changes to take effect. You can view the first several entries in the new error log on restart to validate that the authentication mode is correct. It will say (for mixed):
date/time Server Authentication Mode is MIXED.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With