views:

32

answers:

1

Does anyone know how to determine the security mode (Mixed Mode or Windows Authentication) in .NET?

EDIT: I am using normal ADO.NET objects (SqlConnection, SqlCommand, etc) to connect to the database.

Thanks for any and all advice.

Steve

+1  A: 

You can query the registry!

DECLARE @LoginMode int
EXEC master..xp_regread 
     @rootkey = 'HKEY_LOCAL_MACHINE', 
     @key = 'SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\', 
     @value_name = 'LoginMode',
     @value = @LoginMode output
PRINT @LoginMode

1 = SQL
2 = Mixed

The @key may be different depending on your installation. I have a couple instances running.

Dustin Laine
This is excellent! Thanks Dustin, that's exactly what I was looking for!
Steve Danner