SqlConnectionPoolKey key = (SqlConnectionPoolKey) poolKey;
SqlInternalConnection result = null;
SessionData recoverySessionData = null;
+ SqlConnection sqlOwningConnection = owningConnection as SqlConnection;
+ bool applyTransientFaultHandling = sqlOwningConnection != null ? sqlOwningConnection._applyTransientFaultHandling : false;
SqlConnectionString userOpt = null;
if (userOptions != null) {
userOpt = (SqlConnectionString)userOptions;
}
- else if (owningConnection != null) {
- userOpt = (SqlConnectionString)(((SqlConnection)owningConnection).UserConnectionOptions);
+ else if (sqlOwningConnection != null) {
+ userOpt = (SqlConnectionString)(sqlOwningConnection.UserConnectionOptions);
}
- if (owningConnection != null) {
- recoverySessionData = ((SqlConnection)owningConnection)._recoverySessionData;
+ if (sqlOwningConnection != null) {
+ recoverySessionData = sqlOwningConnection._recoverySessionData;
}
if (opt.ContextConnection) {
// Pass DbConnectionPoolIdentity to SqlInternalConnectionTds if using integrated security.
// Used by notifications.
- if (opt.IntegratedSecurity) {
+ if (opt.IntegratedSecurity || opt.Authentication == SqlAuthenticationMethod.ActiveDirectoryIntegrated) {
if (pool != null) {
identity = pool.Identity;
}
SqlConnectionString sseopt = new SqlConnectionString(opt, opt.DataSource, true /* user instance=true */, false /* set Enlist = false */);
- sseConnection = new SqlInternalConnectionTds(identity, sseopt, key.Credential, null, "", null, false);
+ sseConnection = new SqlInternalConnectionTds(identity, sseopt, key.Credential, null, "", null, false, applyTransientFaultHandling: applyTransientFaultHandling);
// NOTE: Retrieve <UserInstanceName> here. This user instance name will be used below to connect to the Sql Express User Instance.
instanceName = sseConnection.InstanceName;
opt = new SqlConnectionString(opt, instanceName, false /* user instance=false */, null /* do not modify the Enlist value */);
poolGroupProviderInfo = null; // null so we do not pass to constructor below...
}
- result = new SqlInternalConnectionTds(identity, opt, key.Credential, poolGroupProviderInfo, "", null, redirectedUserInstance, userOpt, recoverySessionData);
+ result = new SqlInternalConnectionTds(identity, opt, key.Credential, poolGroupProviderInfo, "", null, redirectedUserInstance, userOpt, recoverySessionData, pool, key.AccessToken, applyTransientFaultHandling: applyTransientFaultHandling);
}
return result;
}
connectionTimeout = Int32.MaxValue;
poolingOptions = new DbConnectionPoolGroupOptions(
- opt.IntegratedSecurity,
+ opt.IntegratedSecurity || opt.Authentication == SqlAuthenticationMethod.ActiveDirectoryIntegrated,
opt.MinPoolSize,
opt.MaxPoolSize,
connectionTimeout,