@@ -89,6 +89,7 @@ private static readonly Dictionary<string, SqlColumnEncryptionKeyStoreProvider>
89
89
private IReadOnlyDictionary < string , SqlColumnEncryptionKeyStoreProvider > _customColumnEncryptionKeyStoreProviders ;
90
90
91
91
private Func < SqlAuthenticationParameters , CancellationToken , Task < SqlAuthenticationToken > > _accessTokenCallback ;
92
+ private Func < SSPIContextProvider > _sspiContextProviderFactory ;
92
93
93
94
internal bool HasColumnEncryptionKeyStoreProvidersRegistered =>
94
95
_customColumnEncryptionKeyStoreProviders is not null && _customColumnEncryptionKeyStoreProviders . Count > 0 ;
@@ -648,7 +649,7 @@ public override string ConnectionString
648
649
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( connectionOptions ) ;
649
650
}
650
651
}
651
- ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _accessTokenCallback ) ) ;
652
+ ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _accessTokenCallback , _sspiContextProviderFactory ) ) ;
652
653
_connectionString = value ; // Change _connectionString value only after value is validated
653
654
CacheConnectionStringProperties ( ) ;
654
655
}
@@ -708,7 +709,7 @@ public string AccessToken
708
709
}
709
710
710
711
// Need to call ConnectionString_Set to do proper pool group check
711
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : value , accessTokenCallback : null ) ) ;
712
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : value , accessTokenCallback : null , sspiContextProviderFactory : _sspiContextProviderFactory ) ) ;
712
713
_accessToken = value ;
713
714
}
714
715
}
@@ -731,11 +732,22 @@ public Func<SqlAuthenticationParameters, CancellationToken, Task<SqlAuthenticati
731
732
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( ( SqlConnectionString ) ConnectionOptions ) ;
732
733
}
733
734
734
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : value ) ) ;
735
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : value , sspiContextProviderFactory : _sspiContextProviderFactory ) ) ;
735
736
_accessTokenCallback = value ;
736
737
}
737
738
}
738
739
740
+ /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/SSPIContextProviderFactory/*' />
741
+ public Func < SSPIContextProvider > SSPIContextProviderFactory
742
+ {
743
+ get { return _sspiContextProviderFactory ; }
744
+ set
745
+ {
746
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , credential : _credential , accessToken : null , accessTokenCallback : _accessTokenCallback , sspiContextProviderFactory : value ) ) ;
747
+ _sspiContextProviderFactory = value ;
748
+ }
749
+ }
750
+
739
751
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/Database/*' />
740
752
[ ResDescription ( StringsHelper . ResourceNames . SqlConnection_Database ) ]
741
753
[ ResCategory ( StringsHelper . ResourceNames . SqlConnection_DataSource ) ]
@@ -1030,7 +1042,7 @@ public SqlCredential Credential
1030
1042
_credential = value ;
1031
1043
1032
1044
// Need to call ConnectionString_Set to do proper pool group check
1033
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , accessToken : _accessToken , accessTokenCallback : _accessTokenCallback ) ) ;
1045
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , accessToken : _accessToken , accessTokenCallback : _accessTokenCallback , _sspiContextProviderFactory ) ) ;
1034
1046
}
1035
1047
}
1036
1048
@@ -1078,7 +1090,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessToken(S
1078
1090
throw ADP . InvalidMixedUsageOfCredentialAndAccessToken ( ) ;
1079
1091
}
1080
1092
1081
- if ( _accessTokenCallback != null )
1093
+ if ( _accessTokenCallback != null )
1082
1094
{
1083
1095
throw ADP . InvalidMixedUsageOfAccessTokenAndTokenCallback ( ) ;
1084
1096
}
@@ -1100,7 +1112,7 @@ private void CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCa
1100
1112
throw ADP . InvalidMixedUsageOfAccessTokenCallbackAndAuthentication ( ) ;
1101
1113
}
1102
1114
1103
- if ( _accessToken != null )
1115
+ if ( _accessToken != null )
1104
1116
{
1105
1117
throw ADP . InvalidMixedUsageOfAccessTokenAndTokenCallback ( ) ;
1106
1118
}
@@ -2214,7 +2226,7 @@ public static void ChangePassword(string connectionString, string newPassword)
2214
2226
throw ADP . InvalidArgumentLength ( nameof ( newPassword ) , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2215
2227
}
2216
2228
2217
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , accessTokenCallback : null ) ;
2229
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2218
2230
2219
2231
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2220
2232
if ( connectionOptions . IntegratedSecurity )
@@ -2263,7 +2275,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
2263
2275
throw ADP . InvalidArgumentLength ( nameof ( newSecurePassword ) , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2264
2276
}
2265
2277
2266
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null ) ;
2278
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2267
2279
2268
2280
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2269
2281
@@ -2302,7 +2314,7 @@ private static void ChangePassword(string connectionString, SqlConnectionString
2302
2314
if ( con != null )
2303
2315
con . Dispose ( ) ;
2304
2316
}
2305
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null ) ;
2317
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2306
2318
2307
2319
SqlConnectionFactory . SingletonInstance . ClearPool ( key ) ;
2308
2320
}
0 commit comments