diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java index 22cb47461..ce18ce145 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java @@ -69,6 +69,11 @@ public class SQLServerAuthenticationProviderModule implements Module { myBatisProperties.setProperty("JDBC.schema", environment.getSQLServerDatabase()); myBatisProperties.setProperty("JDBC.username", environment.getSQLServerUsername()); myBatisProperties.setProperty("JDBC.password", environment.getSQLServerPassword()); + + String instance = environment.getSQLServerInstance(); + if (instance != null) + myBatisProperties.setProperty("JDBC.instanceName", instance); + myBatisProperties.setProperty("JDBC.autoCommit", "false"); myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true"); myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1"); diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java index db068b9b8..9b61be0d2 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java @@ -172,6 +172,23 @@ public class SQLServerEnvironment extends JDBCEnvironment { ); } + /** + * Returns the instance name of the SQL Server installation hosting the + * Guacamole database, if any. If unspecified it will be null. + * + * @return + * The instance name of the SQL Server install hosting the Guacamole + * database, or null if undefined. + * + * @throws GuacamoleException + * If an error occurs reading guacamole.properties. + */ + public String getSQLServerInstance() throws GuacamoleException { + return getProperty( + SQLServerGuacamoleProperties.SQLSERVER_INSTANCE + ); + } + /** * Returns the port number of the SQLServer server hosting the Guacamole * authentication tables. If unspecified, this will be the default diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java index dff1c93c3..257c07ed8 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java @@ -44,6 +44,17 @@ public class SQLServerGuacamoleProperties { public String getName() { return "sqlserver-hostname"; } }; + + /** + * The instance name of the SQL Server where the Guacamole database is running. + */ + public static final StringGuacamoleProperty SQLSERVER_INSTANCE = + new StringGuacamoleProperty() { + + @Override + public String getName() { return "sqlserver-instance"; } + + }; /** * The port of the SQLServer server hosting the Guacamole authentication