0

I am able to connect to remote sql server using SQLpro for MSSQL. However, When I am trying to use tsql to connect, i am not able to connect to the database

OS: Macos x

My freetds.conf path: /usr/local/freetds.conf

[global]
    # tds protocol
    tds version =8.0

[MyserverName]
    host = sqlservername
    port = 1433
    tds version = 8.0

When I run tsql command it is throwing me an error commands as follows:

tsql -S MyserverName -p 1433 -U username -P password

or

tsql -H sqlserver -p 1433 _U username -P password

Below are the errors, when I tried to play with above commands

MSG 18452 (severety 14, state 1):
"Login failed. The login is from an untrusted domain and cannot be used with windows authentication"

Error 20002(severity 9):    
"Adaptive Server connection failed"

I believe that sqlpro uses jdbc driver to connect to sqlserver, but however, I think this should even work.

Any suggestions?

Bhargav
  • 454
  • 1
  • 6
  • 15
  • 1
    try to add flag -C – Fabiano Carvalho Sep 28 '17 at 17:56
  • 2
    Looking at the [freetds connection properties](http://www.freetds.org/userguide/odbcconnattr.htm), you may want to add Trusted_Connection No, although it appears to default to no. I also found [Read from the server failed when trying to connect to sql-azure from tsql](https://stackoverflow.com/questions/11721403/read-from-the-server-failed-when-trying-to-connect-to-sql-azure-from-tsql ) which suggests you may want to specify the TDS version before the tsql command. You may also want to look at [https://gist.github.com/tommct/5749453]( [3]: https://gist.github.com/tommct/5749453). – Andrew O'Brien Sep 28 '17 at 18:06
  • Thanks fot the immediete response. But the error is the same. "Login failed. the login trusted domain and cannot be used with windows authentication" – Bhargav Sep 28 '17 at 18:24
  • @AndrewO'Brien@Fabiano Carvalho Seems like sqlpro also has freetds inbuilt for it. If I can find that config. Then it can help me. – Bhargav Sep 28 '17 at 18:58
  • But that is also the same. – Bhargav Sep 28 '17 at 19:17

1 Answers1

0

To connect via tsql with Windows authentication, using DOMAIN in place of the domain name and USERNAME in place of the Windows user, you need to use this format:

tsql -S yourmssql.server.com -p 1433 -U DOMAIN\\username

It should then prompt you for a password and log you in. If you enter the wrong domain password, you'll get the 'untrusted domain' error, and if you don't use two backslashes, you'll get this error: Login failed for user 'DOMAINusername. followed by Adaptive Server connection failed. This has been tested with FreeTDS 0.95 against SQL Server 2014.

If you're still having issues, you may wish to add this to our freetds.conf file:

ntlmv2 = yes

Good luck!

FlipperPA
  • 13,607
  • 4
  • 39
  • 71
  • 1
    I tried the above. But the it is throwing me an error "Login failed. The Login is from untrusted domain and cannot be used with windows authentication". – Bhargav Sep 29 '17 at 19:09