I was using the below code to connect to SQL Azure DB that was using Active Directory Integrated Authentication.
private string GenerateConnectionString(string databaseName, string serverName)
{
SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder();
sqlConnectionBuilder.DataSource = string.Format(
"tcp:{0}.database.windows.net",
serverName);
connBuilder.InitialCatalog = databaseName;
connBuilder.Authentication = SqlAuthenticationMethod.ActiveDirectoryIntegrated;
connBuilder.ConnectTimeout = 30;
return connBuilder.ConnectionString;
}
The authentication is changed from Active Directory Integrated Authentication to Active Directory Universal Authentication to support multi-factor authentication.
I see the enumeration
System.Data.SqlClient.SqlAuthenticationMethod
doesn't have a value for Active Directory Universal Authentication. Is it possible to still use the System.Data.SqlClient
to connect to the DB? If yes, what is
the change I have to do in the code?
A SqlConnection object represents a unique session to a SQL Server data source. With a client/server database system, it is equivalent to a network connection to the server. SqlConnection is used together with SqlDataAdapter and SqlCommand to increase performance when connecting to a Microsoft SQL Server database.
ActiveDirectoryInteractive authentication method is available since the .NET Framework 4.7.2. Not sure if it is the same as "Universal" or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With