Connect to Azure SQL Server via Linux + ODBC + Active Directory Authentication - sql-server

I'm attempting to connect to Azure SQL Server 2017 from Debian 8 or 9. Our SQL Server instance is connected to our Active Directory requiring Active Directory Authentication.
Thus far, I've tried connecting using the Microsoft ODBC Driver in conjunction with unixODBC to no avail.
Recent attempts with FreeTDS haven't worked well either. Errors vary but typically result in server timeouts or being unable to connect to the server altogether.
Are there recommended best practices for making this connection with these constraints?
Here is the recommended connection string for the database in question:
Driver={ODBC Driver 13 for SQL Server};Server=tcp:xxxx.windows.net,1433;Database=xxxx;Uid={your_user_name};Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryPassword
Primarily, I'm unsure about how to configure odbc.ini,odbcinst.ini and freetds.conf to accommodate this connection string.
Details:
FreeTDS Version = 7.4
FreeTDS Protocol = 1.00.92
MS ODBC Driver Version = 13.1

Related

Connect the IIS Web Server MSSQL from Linux shared hosting

I have deployed the Laravel web application on the Linux A2 shared hosting server. There is I want to use sqlsrv driver to connect the MSSQL database.
The MSSQL database is on the IIS web server. I had enabled pdo_sqlsrv, pdo_odbc, odbc, and sqlsrv extension in my server, opened the 1433 port to communicate, and my Linux server is whitelisted at the IIS web server too. But, when I try to connect it gives me the below error.
Code: -49
Error: This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712.
I was gone through many solutions but no success.

Connecting to Azure SQL Data warehouse with active directory authentication using python from Ubuntu machine

I am trying to connect to azure sql database with active directory authentication using pyodbc on an ubuntu machine. I installed all the required packages on the server (pyodbc, unixodbc etc) and also installed sql server 17 odbc driver.
My server is ubuntu 18.04, so only odbc sql server 17 drivers are supported. The connection wont work with odbc 13 drivers.
I use the below connection details:
import pyodbc
server = 'xxxx.database.windows.net'
database = 'xxxx'
username = 'xxx#xxx.org'
password = 'xxxxx'
driver= '{ODBC Driver 17 for SQL Server}'
auth= 'ActiveDirectoryPassword'
conn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+',1433;DATABASE='+database+';UID='+username+';PWD='+ password+';Authentication=ActiveDirectoryPassword')
When I run the above connection details I face the below timeout error:
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
I even tried creating a connection string and using the below details but I still face the same issue.
pyodbc.connect(connection_string)
Am I missing any configurations? Please note that I tried this from a windows machine and was successful once I installed Microsoft Active Directory Authentication library for MS SQL Server and then by registering adalsql.dll.

Connect SQL Server from SQL Developer

I searched through all threads on the web available, but none could help me.
I am trying to connect to SQL Server engine from SQL Developer. In order to do that I enabled Named Pipes and TCP/IP from SQL Configuration Manager.
Then I tried different drivers:
I tried Microsoft JDBC driver for SQL Server - I cannot choose in connection manager SQL Server database type, so it does not work..
I tried jTDS driver instead, and it worked - I can choose SQL Server database type, but then all I get is an error informing that it cannot connect to Microsoft SQL Server on localhost (I tried localhost, name of my computer, none of which worked).
Is there anything more I can do?
EDIT
This is what I have so far:
SECOND EDIT
I had more problems:
With error saying
Status: Failur-I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property
Using windows authentication, I still got asked for username and password.
(All details and solutions in my answer below)
We only support the jTDS driver for SQL Server and Sybase ASE connections, so that's the way to go.
After that, it's up to you to get a correct connection string to your SQL Server system.
Make sure you have the right port in addition to your 'localhost' network location for your SQL Server instance.
This is using version 19.1 of SQL Developer to connect to a SQL2012 instance overseas..
Actually there were more problems, which I'll post here along with solutions:
In order to ba able to connect SQL Server database type from SQL developer it is needed to install jTDS driver, as already mentioned. Other types are not supported by SQL Developer.
Next thing was to configure with SQL Configuration Manager (the easiest way IMO) SQL Server to listen on IP port 1433, not dynamic, as was previously set. In order to do that in configuration manager I had to go to SQL Server Network Configuration and make appropriate changes. More here.
Next I had problem:
Status: Failur-I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property
Which was the fault of missing file, solution was placing file ntlmauth.dll to the /jdk/bin in SQL Developer directory.
I chose Windows authentication, which apparently is not supported by jTDS, so I needed to create user in SQL Server, which I use to connect SQL Server from SQL Developer.
After all that, I had it working.

Classic ASP cannot connect to SQL database after TLS 1.0 removed from server

I have an IIS web application which connects to a SQL Server like this:
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open("DRIVER={SQL Server};SERVER=servername;DATABASE=dbname;UID=username;PASSWORD=pwd)
Recently I started getting the following error:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error
When I asked my server admin what this meant, he said that they had recently removed TLS 1.0 from the IIS server my web application is mounted on. He made sure the new SQL ODBC 13 drivers were installed on the web server, but it did not help.
Although the web app has never had a DSN before, we created one for it using the ODBC 13 driver. When I tried connecting like this:
objConn.Open "DSNname"
I got the following error:
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
I looked up ConnectionStrings.com to see if there were a way of specifying a different driver. I tried this:
objConn.Open("DRIVER={SQL Server Native Client 13.0};SERVER=servername;DATABASE=dbname;UID=username;PASSWORD=pwd)
And this is the error message that was produced:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Don't know what else to do. Any ideas?
We had to update 3 servers that are running several Classic ASP websites. The main reason was we need to implement Twillio API SMS messaging wich required TLS 1.0 and TLS 1.1 to be disabled/removed.
It took several days and we had the websites go up and down through the process.
I wrote a blog post to document the process for other team members. I hope it helps.
https://dhali.com/programming/tls-1-2-with-classic-asp/
Here are the outlined steps:
https://www.ssllabs.com/ssltest to get the current TLS Configuration
Using IISCrypto Tool we updated the Registry Files on the server
Ran https://www.ssllabs.com/ssltest to prove TLS 1.0 and 1.1 removed
Update ODBC to the latest ver supports TLS 1.2 [Microsoft® ODBC Driver 13.1 for SQL Server]
Update the connection string to use the current ODBC SQL 13 driver
The specified DSN contains an architecture mismatch between the Driver and Application
You can create either a 32bit DSN or a 64bit DSN. You need to create one matching the bitness of your program. Probably 32-bit.

Error Running Sonar connected to SQL Server 2005. SONAR.dbo.rules for column description

When I start Sonar (StartSonar.bat), I get the following error in the log file.
Wrong column type in SONAR.dbo.rules for column description.
Found: ntext, expected: nvarchar(max)
Looking at the column in SQL Server Management Studio it is nvarchar(max)
I'm running:
DB: SQL Server 2005
OS: Windows 7 64 bit
Sonar: 2.11
Tried these drivers:
sqljdbc-1.2.2828.100.jar
sqljdbc4.jar (Microsoft SQL Server JDBC Driver 2.0)
sqljdbc4.jar (Microsoft SQL Server JDBC Driver 3.0)
sqljdbc4.jar (Microsoft SQL Server JDBC Driver 4.0)
My MSSQL Properties:
sonar.jdbc.url: jdbc:sqlserver://localhost;databaseName=SONAR;
sonar.jdbc.driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
sonar.jdbc.validationQuery: select 1
sonar.jdbc.dialect: mssql
I'm using a user name and password (SQL Authentication) to connect the DB
Note to self: When trying to connect to MSSQL remember to Enable TCP/IP. This is found in the SQL Sever Configuration Manager;SQL Server 2005 Network Configuration;Protocols for MSSQLSERVER;TCP/IP
I thought it might be a driver issue, but I'm not sure
Anyone else seen this?
I wasn't able to solve this via the sqljdbc drivers so I took some advise from another post and fell back to the jTDS driver http://jtds.sourceforge.net/index.html
The post I used was Sonar MsSql Database Issue
My Setup:
Sonar 2.11 unzipped to C:\Sonar\sonar-2.11
The steps I made (paraphrased)
Download jTDS drivers from jTDS Drivers Unzip it somewhere, I suggest C:\jDST
Add the DLL to the system path. (C:\jDST\jtds-1.2.5-dist\x64\SSO)
Copy the jar file (C:\jDST\jtds-1.2.5-dist\jtds-1.2.5.jar) to the extensions folder
(C:\Sonar\sonar-2.11\extensions\jdbc-driver\mssql)
Update the sonar.properties
sonar.jdbc.url: jdbc:jtds:sqlserver://localhost:1433/SONAR
sonar.jdbc.driverClassName: net.sourceforge.jtds.jdbc.Driver
sonar.jdbc.validationQuery: select 1
sonar.jdbc.dialect: mssql
Note: in case you connect to the named instance, this must be specified explicitly in the connection URL: jdbc:jtds:sqlserver://localhost/SONAR;instance=SQLEXPRESS
Run the bat file StartSonar.bat (C:\Sonar\sonar-2.11\bin\windows-x86-64\StartSonar.bat)
Check your logs and go to the site http:// localhost:9000

Resources