dbcli / mssql-cli

A command-line client for SQL Server with auto-completion and syntax highlighting
BSD 3-Clause "New" or "Revised" License
1.35k stars 192 forks source link

mssql-cli unable to login with domain authentication #461

Open mokadar opened 4 years ago

pensivebrian commented 4 years ago

Did you specify the -E option when starting mssql-cli? If so, some more details would help. Could you specify mssql-cli version, error text, python version, and OS platform/distribution?

pratio commented 3 years ago

I have the same issue, i am trying to use domain auth but on a mac. Is it possible?

iainworkman commented 3 years ago

Did you specify the -E option when starting mssql-cli? If so, some more details would help. Could you specify mssql-cli version, error text, python version, and OS platform/distribution?

It looks as if the -E option would be to use the integrated authentication from the client machine. I believe the issue here is with an Sql Server which is authenticating users against the domain. This is certainly the case which I am experiencing.

SQL Server 2016 authenticating against a domain running AD 2016.

The client machine is MacOS Catalina, mssql-cli v1.0.0 running under a Python 3.8.2 interpreter.

In our case with have a server (let's call it sql-server-01.domain.com) hosting a database called MY-DB, which is authenticating its users against the domain DOMAIN.

mssql-cli -S sql-server-01.domain.com -d MY-DB -U DOMAIN/user -P *****
Error message: Login failed for user 'DOMAIN/user'.

I can verify that the configuration is correct from the server side using pymssql:

import pymssql

pymssql.connect(
  server='sql-server-01.domain.com',
  user='DOMAIN/user',
  password='*****',
  database='MY_DB'
)
onionpsy commented 2 years ago

any news regarding this issue? this is the exception I receive with the --enable-sqltoolsservice-logging option:

   at Microsoft.SqlTools.Utility.Logger.Close() in D:\a\1\s\src\Microsoft.SqlTools.Hosting\Utility\Logger.cs:line 79
   at Microsoft.SqlTools.ServiceLayer.Program.Main(String[] args) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Program.cs:line 27
Traceback (most recent call last):
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/jsonrpc/contracts/request.py", line 51, in get_response
    response = self.json_rpc_client.get_response(self.request_id, self.owner_uri)
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/jsonrpc/jsonrpcclient.py", line 84, in get_response
    raise self.exception_queue.get()
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/jsonrpc/jsonrpcclient.py", line 124, in _listen_for_response
    response = self.reader.read_response()
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/jsonrpc/jsonrpcclient.py", line 272, in read_response
    while (not self.needs_more_data or self.read_next_chunk()):
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/jsonrpc/jsonrpcclient.py", line 326, in read_next_chunk
    raise EOFError(u'End of stream reached, no output.')
EOFError: End of stream reached, no output.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/main.py", line 122, in <module>
    main()
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/main.py", line 115, in main
    run_cli_with(mssqlcli_options)
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/main.py", line 52, in run_cli_with
    mssqlcli.connect_to_database()
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/mssql_cli.py", line 278, in connect_to_database
    owner_uri, error_messages = self.mssqlcliclient_main.connect_to_database()
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/mssqlcliclient.py", line 91, in connect_to_database
    owner_uri, error_messages = self._execute_connection_request_with(connection_params)
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/mssqlcliclient.py", line 180, in _execute_connection_request_with
    response = connection_request.get_response()
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/jsonrpc/contracts/request.py", line 67, in get_response
    return self.response_error(error)
  File "/home/kali/.local/lib/python3.9/site-packages/mssqlcli/jsonrpc/contracts/connectionservice.py", line 22, in response_error
    u'ownerUri': cls.owner_uri,
AttributeError: type object 'ConnectionRequest' has no attribute 'owner_uri'
azinsharaf commented 2 years ago

@iainworkman I am able to login with a domain account from a windows client machine. (i used backslash) give it a try.

mssql-cli -S SQLINSTANCENAME -d MY-DB -U DOMAIN\user -P ***** -E

csolje commented 2 years ago

I am using a Windows box and I get the following error image

azinsharaf commented 1 year ago

@csolje this is a different error. as far as i know python3.10 is not supported. I am using 3.9.11 on Win and mssql-cli works.

csolje commented 1 year ago

@azinsharaf I will try that out

csolje commented 1 year ago

@azinsharaf how are you using it in 3.9.11?

Do you have install the latest one also?