0

I'm trying to connect a .Net Core application running in a Linux container to a SQL Server database. Our DBA's require us to use AD users to connect to SQL Server. Another team is using NodeJS and seriate to connect using an AD user and password. Using those same creds in .Net Core is giving me a Login failed for user error. Am I missing something in the connection string?

DataSource=MyServer;Initial Catalog=MyDatabase;User Id=MyUsername;Password=MyPassword;Encrypt=true;

5
  • Maybe the connection string would be helpful to answer your question. Please, add it. Also, SQL Server might have a log error with more details. Can you see SQL Server error log?
    – Ronaldo
    Aug 28, 2020 at 0:22
  • 1
    Are you specifying the username and password in the connection string? If so, that's not how AD works. You can't put AD credentials in a connection string no matter what you're using, but not all stacks support AD auth anyway. Aug 28, 2020 at 0:30
  • I added the connection string. It works from a nodejs app using seriate npm package which wraps node-mssql package and uses the msnodesqlv8 driver.
    – Lee O.
    Aug 28, 2020 at 1:32
  • The apps run in a Linux docker image running in mesosphere and are not part of the domain. From what I can tell, that shouldn’t be possible but it is working for the nodejs team.
    – Lee O.
    Aug 28, 2020 at 1:33
  • Looks like the nodejs packages are using the TDS protocol which uses NTLM to authenticate using a domain account and username/password. Appears that .Net Core does not support this.
    – Lee O.
    Aug 28, 2020 at 2:00

1 Answer 1

0

NTLM auth is not supported in official SqlClient package as below link https://github.com/dotnet/SqlClient/issues/143

However, a talent guy provided a temporary solution here https://github.com/dotnet/SqlClient/issues/31

So, you have to fork a dotnet SqlClient repo and add this talent code in https://github.com/dotnet/SqlClient/blob/v4.1.0/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs#L8403

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.