@@ -73,6 +73,8 @@ private static Dictionary<string, SqlColumnEncryptionKeyStoreProvider> s_systemC
73
73
74
74
private Func < SqlAuthenticationParameters , CancellationToken , Task < SqlAuthenticationToken > > _accessTokenCallback ;
75
75
76
+ private Func < SSPIContextProvider > _sspiContextProviderFactory ;
77
+
76
78
internal bool HasColumnEncryptionKeyStoreProvidersRegistered =>
77
79
_customColumnEncryptionKeyStoreProviders is not null && _customColumnEncryptionKeyStoreProviders . Count > 0 ;
78
80
@@ -751,7 +753,7 @@ public string AccessToken
751
753
752
754
_accessToken = value ;
753
755
// Need to call ConnectionString_Set to do proper pool group check
754
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , _accessToken , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , null ) ) ;
756
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , _accessToken , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , null , _sspiContextProviderFactory ) ) ;
755
757
}
756
758
}
757
759
@@ -773,11 +775,24 @@ public Func<SqlAuthenticationParameters, CancellationToken, Task<SqlAuthenticati
773
775
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( ( SqlConnectionString ) ConnectionOptions ) ;
774
776
}
775
777
776
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , null , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , value ) ) ;
778
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , null , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , value , _sspiContextProviderFactory ) ) ;
777
779
_accessTokenCallback = value ;
778
780
}
779
781
}
780
782
783
+ /// <summary>
784
+ /// Gets or sets a <see cref="SSPIContextProvider"/>.
785
+ /// </summary>
786
+ public Func < SSPIContextProvider > SSPIContextProviderFactory
787
+ {
788
+ get { return _sspiContextProviderFactory ; }
789
+ set
790
+ {
791
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , null , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , _accessTokenCallback , value ) ) ;
792
+ _sspiContextProviderFactory = value ;
793
+ }
794
+ }
795
+
781
796
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml' path='docs/members[@name="SqlConnection"]/CommandTimeout/*' />
782
797
[
783
798
DesignerSerializationVisibility ( DesignerSerializationVisibility . Hidden ) ,
@@ -862,7 +877,7 @@ override public string ConnectionString
862
877
CheckAndThrowOnInvalidCombinationOfConnectionOptionAndAccessTokenCallback ( connectionOptions ) ;
863
878
}
864
879
}
865
- ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , _accessTokenCallback ) ) ;
880
+ ConnectionString_Set ( new SqlConnectionPoolKey ( value , _credential , _accessToken , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , _accessTokenCallback , _sspiContextProviderFactory ) ) ;
866
881
_connectionString = value ; // Change _connectionString value only after value is validated
867
882
CacheConnectionStringProperties ( ) ;
868
883
}
@@ -1213,7 +1228,7 @@ public SqlCredential Credential
1213
1228
_credential = value ;
1214
1229
1215
1230
// Need to call ConnectionString_Set to do proper pool group check
1216
- ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , _accessToken , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , _accessTokenCallback ) ) ;
1231
+ ConnectionString_Set ( new SqlConnectionPoolKey ( _connectionString , _credential , _accessToken , _serverCertificateValidationCallback , _clientCertificateRetrievalCallback , _originalNetworkAddressInfo , _accessTokenCallback , _sspiContextProviderFactory ) ) ;
1217
1232
}
1218
1233
}
1219
1234
@@ -2775,7 +2790,7 @@ public static void ChangePassword(string connectionString, string newPassword)
2775
2790
throw ADP . InvalidArgumentLength ( "newPassword" , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2776
2791
}
2777
2792
2778
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , serverCertificateValidationCallback : null , clientCertificateRetrievalCallback : null , originalNetworkAddressInfo : null , accessTokenCallback : null ) ;
2793
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential : null , accessToken : null , serverCertificateValidationCallback : null , clientCertificateRetrievalCallback : null , originalNetworkAddressInfo : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2779
2794
2780
2795
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2781
2796
if ( connectionOptions . IntegratedSecurity || connectionOptions . Authentication == SqlAuthenticationMethod . ActiveDirectoryIntegrated )
@@ -2831,7 +2846,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
2831
2846
throw ADP . InvalidArgumentLength ( "newSecurePassword" , TdsEnums . MAXLEN_NEWPASSWORD ) ;
2832
2847
}
2833
2848
2834
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , serverCertificateValidationCallback : null , clientCertificateRetrievalCallback : null , originalNetworkAddressInfo : null , accessTokenCallback : null ) ;
2849
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , serverCertificateValidationCallback : null , clientCertificateRetrievalCallback : null , originalNetworkAddressInfo : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2835
2850
2836
2851
SqlConnectionString connectionOptions = SqlConnectionFactory . FindSqlConnectionOptions ( key ) ;
2837
2852
@@ -2876,7 +2891,7 @@ private static void ChangePassword(string connectionString, SqlConnectionString
2876
2891
throw SQL . ChangePasswordRequires2005 ( ) ;
2877
2892
}
2878
2893
}
2879
- SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , serverCertificateValidationCallback : null , clientCertificateRetrievalCallback : null , originalNetworkAddressInfo : null , accessTokenCallback : null ) ;
2894
+ SqlConnectionPoolKey key = new SqlConnectionPoolKey ( connectionString , credential , accessToken : null , serverCertificateValidationCallback : null , clientCertificateRetrievalCallback : null , originalNetworkAddressInfo : null , accessTokenCallback : null , sspiContextProviderFactory : null ) ;
2880
2895
2881
2896
SqlConnectionFactory . SingletonInstance . ClearPool ( key ) ;
2882
2897
}
0 commit comments