JetBrains DataGrip - Azure SQL - connect with Active Directory - Password

有些话、适合烂在心里 提交于 2019-12-22 18:34:31

问题


Is it possible to connect to Azure SQL database the same way as I would with Microsoft SQL Management Studio - the "Active Directory - Password" option.

I followed the instructions from here (JetBrains documentation) but when I select "Use Windows Domain authentication" (as I should for Azure Active Directory) it doesn't let me to enter the credentials as SSMS does.

Everything works fine with SSMS but with DataGrip I have no luck. Is this option just not supported in there?


回答1:


It's possible.

  1. Use JTDS driver, not Microsoft one.
  2. Go to the Advanced tab of data source properties, set USENTLMV2 to true and specify the domain name in the DOMAIN field.
  3. Then enter your Active Directory credentials in user/password fields and click Test Connection.



回答2:


The solution was posted by https://codejuicer.com/, copied from following blog: https://codejuicer.com/2018/08/29/datagrip-and-azure-sql-server-active-directory-howto/

Step 1: Get A Few Required JARs. The main library you’ll be working with is ADAL4J (https://github.com/AzureAD/azure-activedirectory-library-for-java/wiki/ADAL4J-Basics). The simplest way to do this step, in my opinion, is to use a barebones Maven pom.xml. That way you don’t have to compile from source and find all the dependencies manually. Horray!

If you don’t have Maven (https://maven.apache.org/) installed you’ll need it. If you prefer Gradle, I’m sure the same can be accomplished with that.

This is what my pom.xml looks like:

<?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>

Now run this command wherever your pom.xml is at:

mvn clean dependency:copy-dependencies

It will create a “lib” directory containing all the jars you need.

Step 2: Add the JARs to the Azure (Microsoft) Driver 1. In the Data Sources and Drivers window (File menu), select the Azure (Microsoft) driver. In the Driver files pane, click the + button and select “Custom JARs...“ 2. Navigate to the JARs fetched in Step 1. Select all of them. Your screen should look something like this (aside from the fancy blurs to hide my super secret info). Step 3: Altering the Advanced Connection Options There is only one thing you need to change for Active Directory authentication. The authentication method. It’s really easy.

At this point, I’m assuming you have an existing connection. If not, create one and select the Azure (Microsoft) driver.

Navigate to the Advanced tab. I like to sort the options by Name. However you do it, find the setting named “authentication.”

Click in the Value column and select ActiveDirectoryPassword (if you’re on Windows™ and use integrated AD… select ActiveDirectoryIntegrated). I imagine I don’t have to tell you to “click OK or Apply.”

Success (I hope)! At this point you should be able to log in to your database instance. Of course, that assumes your credentials and hostname are correct. I hope this helps!



来源:https://stackoverflow.com/questions/51097779/jetbrains-datagrip-azure-sql-connect-with-active-directory-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!