dbt-msft / dbt-sqlserver

dbt adapter for SQL Server and Azure SQL
MIT License
204 stars 95 forks source link

can not log into sql server using domain account #430

Open yxl1108 opened 1 year ago

yxl1108 commented 1 year ago

OS: WSL2 / Ubuntu 20.04.6 LTS (Focal Fossa) Driver: Microsoft ODBC Driver 18 for SQL Server

Installation: curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 apt-get install -y unixodbc-dev gnupg libkrb5-dev pkg-config

dbt profile.yml: local: type: sqlserver driver: 'ODBC Driver 18 for SQL Server' server: sql-server-instance.domain.com port: 1433 trust_cert: true database: database_name schema: dbo authentication: ActiveDirectoryPassword user: 'DOMAIN\username' password: 'password' threads: 4

Error: with authentication: ActiveDirectoryPassword

Database Error ('28000', "[28000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user ''. (18456) (SQLDriverConnect)")

without authentication: ActiveDirectoryPassword

Database Error ('28000', "[28000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user 'DOMAIN\\username'. (18456) (SQLDriverConnect)")

Observations: sql server authentication works fine

NicolasPA commented 1 year ago

If it can help, this is what we're using to connect with the Windows user of the current session.

dbt-transform:
  target: local
  outputs:
    local:
      type: sqlserver
      driver: 'ODBC Driver 17 for SQL Server'
      server: my_server\name
      port: 1433
      trusted_connection: True
      encrypt: False
      threads: 2
      database: my_db
      schema: my_local_schema
yxl1108 commented 1 year ago

I see you use trusted_connection here. doesn't this imply it's running on domain joined windows hosts? I am running dbt for sql server on ubuntu, which is not domain joined.

NicolasPA commented 1 year ago

Yes, it's all Windows.

romiof commented 7 months ago

@yxl1108 as far I know, you need to login with a SQL Account.

AD Accounts, can only login to a SQL Server using Trusted Connection when you had logged with the same account at your machine.

At my setup, I have a dedicated SQL Account for dbt jobs.

pandatrooper commented 1 month ago

@yxl1108 Were you able to resolve this one ?