Connection to Azure SQL database, using Azure Active Directory Integrated authentication (AAD)

3 ビュー (過去 30 日間)
Stephane
Stephane 2020 年 3 月 6 日
コメント済み: Tobias Van Damme 2020 年 9 月 18 日
Using Matlab 2019b.
I used to connect to a SQL using Windows authentication as such, using jdbc 7.2:
javaaddpath('C:\Program Files\Microsoft JDBC DRIVER 7.2 for SQL Server\sqljdbc_7.2\enu\mssql-jdbc-7.2.2.jre8.jar');
conn = database('my_database;applicationIntent=ReadOnly;','','', 'Vendor', 'Microsoft SQL Server', 'Server', 'aaa.bbb.com', 'AuthType', 'Windows')
The code above used to work perfectly. The server expects clients with read-only intent. Notice that applicationIntent=ReadOnly is part of the connection string, as opposed to name-value pairs, which are not handled properly by the java driver. That was the only way to get applicationIntent value through (Matlab, JDBC, etc.) up to the server.
The database recently migrated to an Azure server, using Azure Active Directory - Integrated authentication. The authentication type is out of my control - it's a requirement.
Using Microsoft SQL Server Management Studio, I can connect successfully and browse the database, exactly as prior to the migration. I only had to update the server URL, and change the authentication method to AAD-Integrated in the SSMS object explorer connection options.
Back to Matlab (2019b), I don't see how to update the database() options to use AAD. I tried from databaseExplorer too, with no luck. AAD does not show up in the dropdown menus for Microsoft SQL Server, and I wouldn't know which options to specify for a database of type "Other".
My question is: how can I connect Matlab to a Microsoft Azure SQL database using AAD - Integrated authentication?
  2 件のコメント
Tobias Van Damme
Tobias Van Damme 2020 年 9 月 18 日
Can I revive this topic once again? I am attempting the same and haven't found a solution yet. With regards to the "Other" database type option, I did find what to fill in. According to https://nl.mathworks.com/help/database/ug/other-odbc-compliant-or-jdbc-compliant-databases.html and https://docs.microsoft.com/en-us/sql/connect/jdbc/working-with-a-connection?view=sql-server-ver15, I concluded that for a Microsoft SQL server you have to fill in
Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
URL = jdbc:sqlserver://yourserver.database.windows.net:1433;database=yourdatabase;user=yourusername;password=yourpassword;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;authentication=ActiveDirectoryPassword
I havent been able to get it to fully work due to other java+matlab related issues so I cant verify that this is the solution, but I have the feeling that this should work. Perhaps the user=yourusername;password=yourpassword; can be dropped as there are text fields for that in GUI as well.
Hopefully other more experienced people can weigh in to finally find a solution to this question.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by