【问题标题】:JetBrains DataGrip - Azure SQL - connect with Active Directory - PasswordJetBrains DataGrip - Azure SQL - 与 Active Directory 连接 - 密码
【发布时间】:2018-12-08 09:58:01
【问题描述】:

是否可以像使用 Microsoft SQL Management Studio 一样连接到 Azure SQL 数据库 - “Active Directory - 密码”选项。

I followed the instructions from here (JetBrains documentation) 但是当我选择“使用 Windows 域身份验证”(我应该为 Azure Active Directory)时,它不允许我像 SSMS 那样输入凭据。

SSMS 一切正常,但使用 DataGrip 我没有运气。那里不支持这个选项吗?

【问题讨论】:

    标签: azure-active-directory datagrip ssms-2016


    【解决方案1】:

    这是可能的。

    1. 使用 JTDS 驱动程序,而不是 Microsoft 驱动程序。
    2. 转到数据源属性的高级选项卡,将 USENTLMV2 设置为 true 并在 DOMAIN 字段中指定域名。
    3. 然后在用户/密码字段中输入您的 Active Directory 凭据并单击测试连接。

    【讨论】:

    • 我得到的只是:连接到 SQL Server (jTds) - xxx@xxx.database.windows.net 失败。 [S1000][40607] 此版本的 SQL Server 不支持 Windows 登录。
    • 啊,对不起,那你需要做一些操作:intellij-support.jetbrains.com/hc/en-us/community/posts/…
    • 感谢您的链接,我希望清楚如何处理该问题,但问题本身似乎尚未解决且非常不清楚。
    • 不知道为什么这被否决了。它完全适合我。
    【解决方案2】:

    解决方案由https://codejuicer.com/发布,复制自以下博客:https://codejuicer.com/2018/08/29/datagrip-and-azure-sql-server-active-directory-howto/

    第 1 步: 获取一些必需的 JAR。您将使用的主库 是 ADAL4J (https://github.com/AzureAD/azure-activedirectory-library-for-java/wiki/ADAL4J-Basics)。 在我看来,执行此步骤的最简单方法是使用准系统 Maven pom.xml。这样你就不必从源代码编译并找到 手动的所有依赖项。万岁!

    如果您没有安装 Maven (https://maven.apache.org/),您将 需要它。如果你更喜欢 Gradle,我相信同样可以做到 用那个。

    这就是我的 pom.xml 的样子:

    <?xml version="1.0" encoding="UTF-8"?>
    <project
        xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.foo</groupId>
      <artifactId>bar</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <dependencies>
      <dependency>
              <groupId>com.microsoft.azure</groupId>
          <artifactId>adal4j</artifactId>
          <version>1.6.2</version>
      </dependency>
      </dependencies>
      <build>
        <directory>lib</directory>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <configuration>
              <outputDirectory>
                ${project.build.directory}
              </outputDirectory>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </project>
    

    现在在 pom.xml 所在的任何位置运行此命令:

    mvn clean dependency:copy-dependencies
    

    它将创建一个“lib”目录,其中包含您需要的所有 jar。

    第 2 步: 将 JAR 添加到 Azure (Microsoft) 驱动程序 1. 在数据源和驱动程序窗口(文件菜单)中,选择 Azure (Microsoft) 驱动程序。在驱动程序文件窗格中,单击 + 按钮 并选择“自定义 JAR...” 2. 导航到在步骤 1 中获取的 JAR。选择所有这些 JAR。 你的屏幕应该看起来 像这样的东西(除了花哨的模糊来隐藏我的超级 秘密信息)。 第 3 步: 更改高级连接选项 只有一个 Active Directory 身份验证需要更改的内容。这 身份验证方法。真的很简单。

    此时,我假设您有一个现有的连接。如果不, 创建一个并选择 Azure (Microsoft) 驱动程序。

    导航到“高级”选项卡。我喜欢按名称对选项进行排序。 不管你怎么做,找到名为“身份验证”的设置。

    单击值列并选择 ActiveDirectoryPassword(如果 您在 Windows™ 上并使用集成 AD... 选择 ActiveDirectory 集成)。 我想我不必告诉你“点击确定或应用”。

    成功(我希望)!此时您应该可以登录到您的 数据库实例。当然,这假设您的凭据和 主机名是正确的。我希望这会有所帮助!

    【讨论】:

    • 只添加adal4j jar应该不够吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-11
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多