WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 442a698

Browse files
author
Allan Cascante
committed
When parsing a connection string don't default to AzureMFA if the auth method is not, SqlLogin or Integrated or AzureMFA then return null as the AuthenticationType
1 parent 0d57924 commit 442a698

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,16 +1749,31 @@ await Task.Factory.StartNew(() => Task.Run(async () => {
17491749
public ConnectionDetails ParseConnectionString(string connectionString)
17501750
{
17511751
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);
1752+
bool isAzureMFA = builder.Authentication == SqlAuthenticationMethod.ActiveDirectoryInteractive; // Azure Multi-Factor Authentication
1753+
bool isSqlLogin = builder.Authentication == SqlAuthenticationMethod.SqlPassword;// SQL username/password
1754+
bool isIntegrated = builder.IntegratedSecurity; // Windows Integrated Security
1755+
string Authenticationtype = null;
1756+
1757+
if (isAzureMFA)
1758+
{
1759+
Authenticationtype = "AzureMFA";
1760+
}
1761+
else if(isSqlLogin)
1762+
{
1763+
Authenticationtype = "SqlLogin";
1764+
}
1765+
else if (isIntegrated)
1766+
{
1767+
Authenticationtype = "Integrated";
1768+
}
17521769

17531770
// Set defaults as per MSSQL connection property defaults, not SqlClient's Connection string buider defaults
17541771
ConnectionDetails details = new ConnectionDetails()
17551772
{
17561773
ApplicationIntent = defaultBuilder.ApplicationIntent != builder.ApplicationIntent ? builder.ApplicationIntent.ToString() : null,
17571774
ApplicationName = defaultBuilder.ApplicationName != builder.ApplicationName ? builder.ApplicationName : ApplicationName,
17581775
AttachDbFilename = defaultBuilder.AttachDBFilename != builder.AttachDBFilename ? builder.AttachDBFilename.ToString() : null,
1759-
AuthenticationType = builder.IntegratedSecurity ? "Integrated" :
1760-
((builder.Authentication == SqlAuthenticationMethod.SqlPassword || builder.Authentication == SqlAuthenticationMethod.NotSpecified)
1761-
? "SqlLogin" : "AzureMFA"),
1776+
AuthenticationType = Authenticationtype,
17621777
ConnectRetryCount = defaultBuilder.ConnectRetryCount != builder.ConnectRetryCount ? builder.ConnectRetryCount : 1,
17631778
ConnectRetryInterval = defaultBuilder.ConnectRetryInterval != builder.ConnectRetryInterval ? builder.ConnectRetryInterval : 10,
17641779
ConnectTimeout = defaultBuilder.ConnectTimeout != builder.ConnectTimeout ? builder.ConnectTimeout : 30,

0 commit comments

Comments
 (0)