In my different web applications I use both ways, however, I would like to learn which method is better:
1: server=localhost;database=x; integrated security=SSPI;persist security info=False; Trusted_Connection=Yes;
2: server=localhost;database=x;uid=sa;pwd=y;
In my web application, for each database query, I open a connection and then close the connection.
So I am pretty much using the regular style such as:
using (SqlConnection connection = new SqlConnection(srConnectionString))
{
connection.Open();
using (SqlDataAdapter DA = new SqlDataAdapter(strQuery, connection))
{
DA.Fill(dSet);
}
}
You can safely assume that there are hundreds or even thousands of queries at any given second.
My questions:
Are there any performance wise difference between 2 authentication methodology?
Are there any security difference between 2 authentication methodology?
I don't allow remote connections to the SQL Server. So only local connections are allowed.
Operating system Windows Server 2019
sa
login in your connection. You shouldn't have thesa
as your app user unless absolutely necessary. If your application would happen to suffer a SQL Injection attack, withsa
credential the attacker would be able to do anything with your database and wouldn't even have the trouble of searching for the names of objects assa
has access to a bunch of default objects that exists in a SQL Server instance. See this.