Sometimes I see weird issues with SQL Servers, and it helps me in understanding how the software works. In this blog, I would share my learning about the cause of Server Authentication mode disabled. If it is disabled, how would you know what mode is used by SQL Server?
Here is the screenshot of my problem statement. Weird, right?
Logically thinking, if a radio button group is greyed out with nothing checked which means the value is not as expected by SQL Server Management Studio (SSMS). I captured profiler and looked at the script which is executed when we click on the “Security” tab under the “Server > Properties” window. Out of the long script, I have made a shorter version which is used to get the value to populate the server authentication. Below is the secret sauce which populates the radio button.
DECLARE @HkeyLocal NVARCHAR(18) DECLARE @MSSqlServerRegPath NVARCHAR(31) DECLARE @InstanceRegPath SYSNAME DECLARE @SmoLoginMode INT; SELECT @HkeyLocal = N'HKEY_LOCAL_MACHINE' SELECT @MSSqlServerRegPath = N'SOFTWARE\Microsoft\MSSQLServer' SELECT @InstanceRegPath = @MSSqlServerRegPath + N'\MSSQLServer' EXEC master.dbo.xp_instance_regread @HkeyLocal ,@InstanceRegPath ,N'LoginMode' ,@SmoLoginMode OUTPUT; SELECT @SmoLoginMode
If the output is 1 then its “Windows Authentication mode” and if the output is 2 then its “SQL Server and Windows Authentication mode”. Feel free to run on your environment and verify it.
WORKAROUND/SOLUTION – Authentication
Now there are two possible reasons, which I can think of, to get the radio button greyed out.
- If the value returned is something other than one or two OR
- There is a failure in executing xp_instance_regread, which could be due to permission or any other reason. The best way would be to run the script and see the output.
Now, the next question would be, how to find the authentication mode used by SQL Server, if the option is greyed out? I would always look at the ERRORLOG file to see line having Authentication mode is.
Here are the two possible values which I have seen.
- Authentication mode is WINDOWS-ONLY.
- Authentication mode is MIXED.
If you are running into the same situation, run the script and check SmoLoginMode. If the value is other than 1 or 2 then you have an issue with registry value. Fix the value and then come back to SSMS. If there is an error while running the script, please comment and let me know. You can always reach out to me on twitter here.
Reference: Pinal Dave (https://blog.sqlauthority.com)