Friday, January 22, 2010

how can I set the authentication mode for a SQLServer from code?

HKLM\Software\Microsoft\Microsoft SQL Server\\MSSQLServer\LoginMode
1 = integrated only, 2-mixed

For you will need to use MSSQL.n, where n relates to the instance you are interested in. You can find the right value by looking at HKLM\Software\Microsoft\Microsoft SQL Server\Instance Names\SQLame, and looking for the value that matches your instance name. SQL Express has an instance name of SQLEXPRESS, and the default SQL 2005 instance has a name of MSSQLSERVER. (on my box ...\Instance Names\SQL\SQLEXPRESS has a value of MSSQL.4)

From here:

Thursday, January 21, 2010