【问题标题】:Gephi and integrated security with SQL ServerGephi 和与 SQL Server 的集成安全性
【发布时间】:2019-10-02 15:35:46
【问题描述】:

我在 Windows 上使用gephi 0.9.2。我可以通过File - Import Database - Edge List 连接到我的 SQL Server (2016),输入所有参数,包括。 gui 中的用户名和密码(这意味着通过 SQL Server 身份验证进行连接)。我想使用集成安全性(“Windows 身份验证”)连接到数据库。我找不到输入连接字符串或以任何其他方式提供该信息的方法。

gephi 0.9.2 有没有办法直接定义到 SQL Server 的连接字符串?

这将完美地完成这项工作:

jdbc:sqlserver://server\instance;databaseName=DBName;integratedSecurity=true;

我只能在漫游配置文件中找到一个二进制文件“EdgeListDatabase”。但这似乎只保存在 gui 中输入的数据。

【问题讨论】:

    标签: sql-server gephi mssql-jdbc


    【解决方案1】:

    这是建立连接的方式(除了通过边缘列表之外别无他法):

    gephi/io/importer/plugin/database/ImporterEdgeList.java

    private void importData() throws Exception {
        //Connect database
        String url = SQLUtils.getUrl(database.getSQLDriver(), database.getHost(), database.getPort(), database.getDBName());
        try {
            report.log("Try to connect at " + url);
            connection = database.getSQLDriver().getConnection(url, database.getUsername(), database.getPasswd());
            report.log("Database connection established");
        }
    

    这是通过 getUrl 从您在 Edge List 中传递的字段形成连接字符串的方式: gephi/io/database/drivers/SQLUtils.java

    public static String getUrl(SQLDriver driver, String host, int port, String dbname) {
            String res = "jdbc:";
            res += driver != null ? driver.getPrefix() : "";
            res += "://";
            res += host != null ? host : "";
            res += ":";
            res += port != 0 ? port : "";
            res += dbname != null ? "/" + dbname : "";
            return res;
        }
    

    这就是在 SQLServerDriver 中建立最终连接的方法: gephi/modules/DBDrivers/src/main/java/org/gephi/io/database/drivers/SQLServerDriver.java

    public Connection getConnection(String connectionUrl, String username, String passwd) throws SQLException {
            //Bug #745414
            if (!connectionUrl.contains(";databaseName=")) {
                String dbname = connectionUrl.substring(connectionUrl.lastIndexOf('/') + 1);
                String url = connectionUrl.substring(0, connectionUrl.lastIndexOf('/'));
                connectionUrl = url + ";databaseName=" + dbname;
            }
    
            return DriverManager.getConnection(connectionUrl, username, passwd);
        }
    

    public static Connection getConnection(String url, String user, String password)

    如果您将主机设置为:您可能能够在主机字段上进行注入: server\instance;integratedSecurity=true;authenticationScheme=javakerberos;password= 如果您将其用作 password=:,您将绕过插入的 res += ":"; 中的语法错误 像往常一样设置 dbName,将端口留空并设置一个虚拟用户名和密码。

    现在您必须希望驱动程序不会推翻 Windows 身份验证,因为您使用凭据调用了 getConnection。

    如果这不起作用,您唯一的方法是将ImporterEdgeList.java插件的源更改为调用getConnection(String url),如果冒号绕过不起作用,则根据database.getHost()手动伪造url。

    类似的东西:

    private void importData() throws Exception {
        //Connect database
        String url = "jdbc:";
        url += driver != null ? database.getSQLDriver().getPrefix() : "sqlserver";
        url += "://";
        url += database.getHost();
        try {
            report.log("Try to connect at " + url);
            connection = database.getSQLDriver().getConnection(url);
            report.log("Database connection established");
        }
    

    通过这个技巧,您可以通过主机变量指定连接字符串的其余部分

    【讨论】:

    • 感谢您的破解!我必须改变三件事:1.主机必须是“[Servername as FQDN];instanceName=[as given];integratedSecurity=true;authenticationScheme=nativeauthentication;password=:”(不带“)2.端口1433(标准)3 . 把 sqljdbc_auth.dll 放到路径里。现在一切都好了。再次感谢
    猜你喜欢
    • 2013-03-04
    • 2012-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多