@@ -88,6 +88,7 @@ private static readonly Dictionary<string, SqlColumnEncryptionKeyStoreProvider>
88
88
private IReadOnlyDictionary < string , SqlColumnEncryptionKeyStoreProvider > _customColumnEncryptionKeyStoreProviders ;
89
89
90
90
private Func < SqlAuthenticationParameters , CancellationToken , Task < SqlAuthenticationToken > > _accessTokenCallback ;
91
+ private Func < SSPIContextProvider > _sspiContextProviderFactory ;
91
92
92
93
internal bool HasColumnEncryptionKeyStoreProvidersRegistered =>
93
94
_customColumnEncryptionKeyStoreProviders is not null && _customColumnEncryptionKeyStoreProviders . Count > 0 ;
@@ -646,7 +647,7 @@ public override string ConnectionString
646
647
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( connectionOptions ) ;
647
648
}
648
649
}
649
- ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _accessTokenCallback ) ) ;
650
+ ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _accessTokenCallback , _sspiContextProviderFactory ) ) ;
650
651
_connectionString = value ; // Change _connectionString value only after value is validated
651
652
CacheConnectionStringProperties ( ) ;
652
653
}
@@ -706,7 +707,7 @@ public string AccessToken
706
707
}
707
708
708
709
// Need to call ConnectionString_Set to do proper pool group check
709
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : value , accessTokenCallback : null ) ) ;
710
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : value , accessTokenCallback : null , sspiContextProviderFactory : _sspiContextProviderFactory ) ) ;
710
711
_accessToken = value ;
711
712
}
712
713
}
@@ -729,11 +730,22 @@ public Func<SqlAuthenticationParameters, CancellationToken, Task<SqlAuthenticati
729
730
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( ( SqlConnectionString ) ConnectionOptions ) ;
730
731
}
731
732
732
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : value ) ) ;
733
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : value , sspiContextProviderFactory : _sspiContextProviderFactory ) ) ;
733
734
_accessTokenCallback = value ;
734
735
}
735
736
}
736
737
738
+ /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/SSPIContextProviderFactory/*' />
739
+ public Func < SSPIContextProvider > SSPIContextProviderFactory
740
+ {
741
+ get { return _sspiContextProviderFactory ; }
742
+ set
743
+ {
744
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : _accessTokenCallback , sspiContextProviderFactory : value ) ) ;
745
+ _sspiContextProviderFactory = value ;
746
+ }
747
+ }
748
+
737
749
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/Database/*' />
738
750
[ ResDescription ( StringsHelper . ResourceNames . SqlConnection_Database ) ]
739
751
[ ResCategory ( StringsHelper . ResourceNames . SqlConnection_DataSource ) ]
@@ -1028,7 +1040,7 @@ public SqlCredential Credential
1028
1040
_credential = value ;
1029
1041
1030
1042
// Need to call ConnectionString_Set to do proper pool group check
1031
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , accessToken : _accessToken , accessTokenCallback : _accessTokenCallback ) ) ;
1043
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , accessToken : _accessToken , accessTokenCallback : _accessTokenCallback , _sspiContextProviderFactory ) ) ;
1032
1044
}
1033
1045
}
1034
1046
@@ -1076,7 +1088,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessToken(S
1076
1088
throw ADP . InvalidMixedUsageOfCredentialAndAccessToken ( ) ;
1077
1089
}
1078
1090
1079
- if ( _accessTokenCallback != null )
1091
+ if ( _accessTokenCallback != null )
1080
1092
{
1081
1093
throw ADP . InvalidMixedUsageOfAccessTokenAndTokenCallback ( ) ;
1082
1094
}
@@ -1098,7 +1110,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCa
1098
1110
throw ADP . InvalidMixedUsageOfAccessTokenCallbackAndAuthentication ( ) ;
1099
1111
}
1100
1112
1101
- if ( _accessToken != null )
1113
+ if ( _accessToken != null )
1102
1114
{
1103
1115
throw ADP . InvalidMixedUsageOfAccessTokenAndTokenCallback ( ) ;
1104
1116
}
@@ -2212,7 +2224,7 @@ public static void ChangePassword(string connectionString, string newPassword)
2212
2224
throw ADP . InvalidArgumentLength ( nameof ( newPassword ) , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2213
2225
}
2214
2226
2215
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , accessTokenCallback : null ) ;
2227
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2216
2228
2217
2229
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2218
2230
if ( connectionOptions . IntegratedSecurity )
@@ -2261,7 +2273,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
2261
2273
throw ADP . InvalidArgumentLength ( nameof ( newSecurePassword ) , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2262
2274
}
2263
2275
2264
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null ) ;
2276
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2265
2277
2266
2278
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2267
2279
@@ -2300,7 +2312,7 @@ private static void ChangePassword(string connectionString, SqlConnectionString
2300
2312
if ( con != null )
2301
2313
con . Dispose ( ) ;
2302
2314
}
2303
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null ) ;
2315
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2304
2316
2305
2317
SqlConnectionFactory . SingletonInstance . ClearPool ( key ) ;
2306
2318
}
0 commit comments