提交 b0967e8c 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #3041 from dbeaver/#3016-mssql-connection

#3016 Use "integratedSecurity" connection property instead of "connection-windows-auth" internal setting.

Former-commit-id: e701557e
......@@ -32,6 +32,7 @@ public class SQLServerConstants {
public static final String PROP_CONNECTION_WINDOWS_AUTH = DBConstants.INTERNAL_PROP_PREFIX + "connection-windows-auth@";
public static final String PROP_SHOW_ALL_SCHEMAS = DBConstants.INTERNAL_PROP_PREFIX + "show-all-schemas@";
public static final String PROP_CONNECTION_INTEGRATED_SECURITY = "integratedSecurity";
// https://support.microsoft.com/en-us/help/321185/how-to-determine-the-version--edition-and-update-level-of-sql-server-a
public static final int SQL_SERVER_2016_VERSION_MAJOR = 13;
......
......@@ -82,9 +82,11 @@ public class SQLServerDataSourceProvider extends JDBCDataSourceProvider implemen
url.append("databaseName=").append(connectionInfo.getDatabaseName());
}
}
/*
if ("TRUE".equalsIgnoreCase(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
url.append(";integratedSecurity=true");
}
*/
} else {
// Sybase
if (isJtds) {
......
......@@ -18,7 +18,9 @@
package org.jkiss.dbeaver.ext.mssql;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.utils.CommonUtils;
/**
* SQLServerUtils
......@@ -35,4 +37,9 @@ public class SQLServerUtils {
public static boolean isDriverJtds(DBPDriver driver) {
return driver.getSampleURL().startsWith("jdbc:jtds");
}
public static boolean isWindowsAuth(DBPConnectionConfiguration connectionInfo) {
return CommonUtils.toBoolean(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH)) ||
CommonUtils.toBoolean(connectionInfo.getProperties().get(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY));
}
}
......@@ -20,6 +20,7 @@ import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ext.mssql.SQLServerConstants;
import org.jkiss.dbeaver.ext.mssql.SQLServerUtils;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
......@@ -93,7 +94,7 @@ public class MSSQLDataSource extends JDBCDataSource implements DBSObjectSelector
@Override
protected String getConnectionUserName(DBPConnectionConfiguration connectionInfo) {
if (CommonUtils.toBoolean(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
if (SQLServerUtils.isWindowsAuth(connectionInfo)) {
return "";
} else {
return super.getConnectionUserName(connectionInfo);
......@@ -102,7 +103,7 @@ public class MSSQLDataSource extends JDBCDataSource implements DBSObjectSelector
@Override
protected String getConnectionUserPassword(DBPConnectionConfiguration connectionInfo) {
if (CommonUtils.toBoolean(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
if (SQLServerUtils.isWindowsAuth(connectionInfo)) {
return "";
} else {
return super.getConnectionUserPassword(connectionInfo);
......
......@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ext.mssql.model;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.generic.model.GenericDataSource;
import org.jkiss.dbeaver.ext.mssql.SQLServerConstants;
import org.jkiss.dbeaver.ext.mssql.SQLServerUtils;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
......@@ -62,7 +63,7 @@ public class SQLServerDataSource extends GenericDataSource {
@Override
protected String getConnectionUserName(DBPConnectionConfiguration connectionInfo) {
if (CommonUtils.toBoolean(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
if (SQLServerUtils.isWindowsAuth(connectionInfo)) {
return "";
} else {
return super.getConnectionUserName(connectionInfo);
......@@ -71,7 +72,7 @@ public class SQLServerDataSource extends GenericDataSource {
@Override
protected String getConnectionUserPassword(DBPConnectionConfiguration connectionInfo) {
if (CommonUtils.toBoolean(connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH))) {
if (SQLServerUtils.isWindowsAuth(connectionInfo)) {
return "";
} else {
return super.getConnectionUserPassword(connectionInfo);
......
......@@ -221,10 +221,7 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
if (windowsAuthenticationButton != null) {
String winAuthProperty = connectionInfo.getProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH);
if (winAuthProperty != null) {
windowsAuthenticationButton.setSelection(Boolean.parseBoolean(winAuthProperty));
}
windowsAuthenticationButton.setSelection(SQLServerUtils.isWindowsAuth(connectionInfo));
enableTexts();
}
showAllSchemas.setSelection(CommonUtils.toBoolean(connectionInfo.getProviderProperty(SQLServerConstants.PROP_SHOW_ALL_SCHEMAS)));
......@@ -252,7 +249,7 @@ public class SQLServerConnectionPage extends ConnectionPageAbstract implements I
connectionInfo.setUserPassword(passwordText.getText());
}
if (windowsAuthenticationButton != null) {
connectionInfo.setProviderProperty(SQLServerConstants.PROP_CONNECTION_WINDOWS_AUTH,
connectionInfo.getProperties().put(SQLServerConstants.PROP_CONNECTION_INTEGRATED_SECURITY,
String.valueOf(windowsAuthenticationButton.getSelection()));
}
if (showAllSchemas != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册