Skip to content

Commit

Permalink
Fix #2679 Support SQL Server Integrated Security
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyeeedar committed Feb 19, 2020
1 parent ea1db69 commit 585eb38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ private static boolean needsUser(String url) {
if (DriverDataSource.DriverType.SNOWFLAKE.matches(url)) {
return !url.contains("user=");
}
if (DriverDataSource.DriverType.SQLSERVER.matches(url)) {
return !url.contains("integratedSecurity=");
}
return true;
}

Expand All @@ -471,6 +474,9 @@ private static boolean needsPassword(String url) {
if (DriverDataSource.DriverType.SNOWFLAKE.matches(url)) {
return !url.contains("private_key_file=");
}
if (DriverDataSource.DriverType.SQLSERVER.matches(url)) {
return !url.contains("integratedSecurity=");
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public static Connection openConnection(DataSource dataSource, int connectRetrie
try {
return dataSource.getConnection();
} catch (SQLException e) {
if ("08S01".equals(e.getSQLState()) && e.getMessage().contains("This driver is not configured for integrated authentication")) {
throw new FlywaySqlException("Unable to obtain connection from database"
+ getDataSourceInfo(dataSource) + ": " + e.getMessage() + "\nTo setup integrated authentication see https://flywaydb.org/documentation/database/sqlserver#windows-authentication.", e);
}

if (++retries > connectRetries) {
throw new FlywaySqlException("Unable to obtain connection from database"
+ getDataSourceInfo(dataSource) + ": " + e.getMessage(), e);
Expand Down

0 comments on commit 585eb38

Please sign in to comment.