Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SqlConnectionString.cs #1359

Merged
merged 6 commits into from
Oct 20, 2021
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ internal static Exception AuthenticationAndIntegratedSecurity()
{
return ADP.Argument(StringsHelper.GetString(Strings.SQL_AuthenticationAndIntegratedSecurity));
}
internal static Exception IntegratedWithPassword()
internal static Exception IntegratedWithUserIDAndPassword()
{
return ADP.Argument(StringsHelper.GetString(Strings.SQL_IntegratedWithPassword));
return ADP.Argument(StringsHelper.GetString(Strings.SQL_IntegratedWithUserIDAndPassword));
}
internal static Exception InteractiveWithPassword()
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@
<data name="SQL_AuthenticationAndIntegratedSecurity" xml:space="preserve">
<value>Cannot use 'Authentication' with 'Integrated Security'.</value>
</data>
<data name="SQL_IntegratedWithPassword" xml:space="preserve">
<value>Cannot use 'Authentication=Active Directory Integrated' with 'Password' or 'PWD' connection string keywords.</value>
<data name="SQL_IntegratedWithUserIDAndPassword" xml:space="preserve">
<value>Cannot use 'Authentication=Active Directory Integrated' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords.</value>
</data>
<data name="SQL_InteractiveWithPassword" xml:space="preserve">
<value>Cannot use 'Authentication=Active Directory Interactive' with 'Password' or 'PWD' connection string keywords.</value>
Expand Down Expand Up @@ -1932,4 +1932,4 @@
<data name="SQL_ParameterDirectionInvalidForOptimizedBinding" xml:space="preserve">
<value>Parameter '{0}' cannot have Direction Output or InputOutput when EnableOptimizedParameterBinding is enabled on the parent command.</value>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -2267,15 +2267,6 @@ internal TdsParser Parser
}
}

internal bool Asynchronous
{
get
{
SqlConnectionString constr = (SqlConnectionString)ConnectionOptions;
return ((null != constr) ? constr.Asynchronous : SqlConnectionString.DEFAULT.Asynchronous);
}
}

//
// INTERNAL METHODS
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,6 @@ internal static class DbConnectionStringDefaults
internal const bool ContextConnection = false;
internal static readonly bool TransparentNetworkIPResolution = !LocalAppContextSwitches.DisableTNIRByDefault;
internal const string NetworkLibrary = "";
internal const bool Asynchronous = false;
#if ADONET_CERT_AUTH
internal const string Certificate = "";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ internal static class DEFAULT
internal static readonly SqlConnectionIPAddressPreference IpAddressPreference = DbConnectionStringDefaults.IPAddressPreference;
#if NETFRAMEWORK
internal static readonly bool TransparentNetworkIPResolution = DbConnectionStringDefaults.TransparentNetworkIPResolution;
internal const bool Asynchronous = DbConnectionStringDefaults.Asynchronous;
internal const bool Connection_Reset = DbConnectionStringDefaults.ConnectionReset;
internal const bool Context_Connection = DbConnectionStringDefaults.ContextConnection;
internal const string Network_Library = DbConnectionStringDefaults.NetworkLibrary;
Expand Down Expand Up @@ -572,17 +571,10 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
throw SQL.AuthenticationAndIntegratedSecurity();
}

#if NETFRAMEWORK
if (Authentication == SqlAuthenticationMethod.ActiveDirectoryIntegrated && (_hasUserIdKeyword || _hasPasswordKeyword))
{
throw SQL.IntegratedWithUserIDAndPassword();
}
cheenamalhotra marked this conversation as resolved.
Show resolved Hide resolved
#else
if (Authentication == SqlAuthenticationMethod.ActiveDirectoryIntegrated && _hasPasswordKeyword)
{
throw SQL.IntegratedWithPassword();
}
#endif

if (Authentication == SqlAuthenticationMethod.ActiveDirectoryInteractive && _hasPasswordKeyword)
{
Expand Down