@@ -90,6 +90,7 @@ private static readonly Dictionary<string, SqlColumnEncryptionKeyStoreProvider>
90
90
private IReadOnlyDictionary < string , SqlColumnEncryptionKeyStoreProvider > _customColumnEncryptionKeyStoreProviders ;
91
91
92
92
private Func < SqlAuthenticationParameters , CancellationToken , Task < SqlAuthenticationToken > > _accessTokenCallback ;
93
+ private SspiContextProvider _sspiContextProvider ;
93
94
94
95
internal bool HasColumnEncryptionKeyStoreProvidersRegistered =>
95
96
_customColumnEncryptionKeyStoreProviders is not null && _customColumnEncryptionKeyStoreProviders . Count > 0 ;
@@ -647,7 +648,7 @@ public override string ConnectionString
647
648
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( connectionOptions ) ;
648
649
}
649
650
}
650
- ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _accessTokenCallback ) ) ;
651
+ ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _accessTokenCallback , _sspiContextProvider ) ) ;
651
652
_connectionString = value ; // Change _connectionString value only after value is validated
652
653
CacheConnectionStringProperties ( ) ;
653
654
}
@@ -707,7 +708,7 @@ public string AccessToken
707
708
}
708
709
709
710
// Need to call ConnectionString_Set to do proper pool group check
710
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : value , accessTokenCallback : null ) ) ;
711
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : value , accessTokenCallback : null , sspiContextProvider : _sspiContextProvider ) ) ;
711
712
_accessToken = value ;
712
713
}
713
714
}
@@ -730,11 +731,22 @@ public Func<SqlAuthenticationParameters, CancellationToken, Task<SqlAuthenticati
730
731
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( ( SqlConnectionString ) ConnectionOptions ) ;
731
732
}
732
733
733
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : value ) ) ;
734
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : value , sspiContextProvider : _sspiContextProvider ) ) ;
734
735
_accessTokenCallback = value ;
735
736
}
736
737
}
737
738
739
+ /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/SspiContextProvider/*' />
740
+ public SspiContextProvider SspiContextProvider
741
+ {
742
+ get { return _sspiContextProvider ; }
743
+ set
744
+ {
745
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : _accessTokenCallback , sspiContextProvider : value ) ) ;
746
+ _sspiContextProvider = value ;
747
+ }
748
+ }
749
+
738
750
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/Database/*' />
739
751
[ ResDescription ( StringsHelper . ResourceNames . SqlConnection_Database ) ]
740
752
[ ResCategory ( StringsHelper . ResourceNames . SqlConnection_DataSource ) ]
@@ -1032,7 +1044,7 @@ public SqlCredential Credential
1032
1044
_credential = value ;
1033
1045
1034
1046
// Need to call ConnectionString_Set to do proper pool group check
1035
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , accessToken : _accessToken , accessTokenCallback : _accessTokenCallback ) ) ;
1047
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , accessToken : _accessToken , accessTokenCallback : _accessTokenCallback , _sspiContextProvider ) ) ;
1036
1048
}
1037
1049
}
1038
1050
@@ -2262,7 +2274,7 @@ public static void ChangePassword(string connectionString, string newPassword)
2262
2274
throw ADP . InvalidArgumentLength ( nameof ( newPassword ) , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2263
2275
}
2264
2276
2265
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , accessTokenCallback : null ) ;
2277
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , accessTokenCallback : null , sspiContextProvider : null ) ;
2266
2278
2267
2279
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2268
2280
if ( connectionOptions . IntegratedSecurity )
@@ -2311,7 +2323,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
2311
2323
throw ADP . InvalidArgumentLength ( nameof ( newSecurePassword ) , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2312
2324
}
2313
2325
2314
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null ) ;
2326
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null , sspiContextProvider : null ) ;
2315
2327
2316
2328
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2317
2329
@@ -2349,7 +2361,7 @@ private static void ChangePassword(string connectionString, SqlConnectionString
2349
2361
{
2350
2362
con ? . Dispose ( ) ;
2351
2363
}
2352
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null ) ;
2364
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null , sspiContextProvider : null ) ;
2353
2365
2354
2366
SqlConnectionFactory . SingletonInstance . ClearPool ( key ) ;
2355
2367
}
0 commit comments