Check For SQL Authentication Type Before Adding Users
While setting up a new team member to run a WPF app locally we ran into an error. It look about 30 minutes to realize our setup SQL script was creating a user in SQL server, but mixed mode authentication was not turned on.
To prevent having to relearn this problem again in the future we’ve added this code to our SQL script, right before the CREATE LOGIN command.
IF (SERVERPROPERTY('IsIntegratedSecurityOnly') != 0) BEGIN THROW 50000, 'SQL Server has not been configured for mixed mode authentication.', 1; END GO
Now if we ever have another team member try to run the setup scripts without mixed mode authentication turned on they’ll get an error telling them exactly what is wrong.