I have two apps that use Integrated Security. One assigns Integrated Security = true
in the connection string, and the other sets Integrated Security = SSPI
.
What is the difference between SSPI
and true
in the context of Integrated Security?
True is only valid if you're using the .NET SqlClient library. It isn't valid when using OLEDB. Where SSPI is bvaid in both either you are using .net SqlClient library or OLEDB.
In my point of view,
If you dont use Integrated security=SSPI,then you need to hardcode the username and password in the connection string which means "relatively insecure" why because, all the employees have the access even ex-employee could use the information maliciously.
Integrated Security=true;
doesn't work in all SQL providers, it throws an exception when used with theOleDb
provider.So basically
Integrated Security=SSPI;
is preferred since works with bothSQLClient
&OleDB
provider.Here's the full set of syntaxes according to MSDN - Connection String Syntax (ADO.NET)
Many questions get answers if we use
.Net Reflector
to see the actual code ofSqlConnection
:)true
andsspi
are the same:EDIT 20.02.2018 Now in .Net Core we can see its open source on github! Search for ConvertValueToIntegratedSecurityInternal method:
https://github.com/dotnet/corefx/blob/fdbb160aeb0fad168b3603dbdd971d568151a0c8/src/System.Data.SqlClient/src/System/Data/Common/DbConnectionOptions.cs
Note that connection strings are specific to what and how you are connecting to data. These are connecting to the same database but the first is using .NET Framework Data Provider for SQL Server. Integrated Security=True will not work for OleDb.
When in doubt use the Visual Studio Server Explorer Data Connections.
According to Microsoft they are the same thing.