-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kerberos authentication doesn't work with NuGet package 2.1.1 #926
Comments
I have since updated one of our .net projects from 2.0.1 to 2.1.1 and see the same issue. Works with 2.0.1. Here's the stack trace for it:
|
Could you please share your connection string? |
Thank you @Code-DJ for moving the issue here. Could you please try this Microsoft.Data.SqlClient nuget package directly from a .net console appliation with the same connection string you are having the issue? |
|
@karinazhou when I click that link it shows "401 - Uh-oh, you do not have access.". |
Microsoft.Data.SqlClient.2.1.0-pull-4fae95f.21054.2.nupkg.zip @Code-DJ Could you try this attachment? You will need to unzip it first since github doesn't allow me to attach the nuget file directly. |
@karinazhou I still get the same error. Did the following:
Note that if fails for the following as well but works for 2.0.1:
|
I'm not sure I follow, is this also reproducible with v2.1.1 or just v2.1.0?
Related issue #825 was fixed in v2.1.1. |
@cheenamalhotra yes, it fails in 2.1.0, 2.1.0-pull-4fae95f.21054.2 and 2.1.1 but works on 2.0.1. |
@Code-DJ Can you also try with 2.0.1-preview1 and 2.0.1-preview2 to see how it works? |
@karinazhou I assume you mean 2.1.0-preview2.20297.7 and 2.1.0-preview1.20235.1. It fails for both. I didn't find any previews for 2.0.1 on https://www.nuget.org/packages/Microsoft.Data.SqlClient/ I no longer have /etc/krb5.conf and it worked for 2.0.1 as well as for Azure Data Studio 1.25* Verified SPN is still active on the server hosting SQL Server. |
@karinazhou ran the following on one of the SQL Server VMs:
It returned the following:
If I run "setspn -l SERVER1", I don't see MSSQLSvc/SERVER1.Domain.local listed. Note that I am connecting to the server from my local machine using my domain user on the mac. |
@Code-DJ Can you try setSPN with port? It should give you something like |
@karinazhou yay! that worked. It is the else condition causing the problem.
|
@Code-DJ Cool 👍 Thank you for confirming this. We will add this information to our wiki to avoid further similar issues. |
@karinazhou is there a work around that doesn't require changing the SPN? I don't manage the SQL servers at my work so I don't have permissions to change SPN. |
Hi @mas-dse-juremigi, can you first try with the nuget package I attached this comment: We have another fix for the instance name which uses named instance in Linux environment. The SPN change is specific to the Kerberos authentication failure. Do you have backslash in the server name? If so, that may be due to another issue which has been fixed in the nuget package I have attached. |
@karinazhou I'm not sure how to do this as I am a python developer, not familiar with .net. |
@mas-dse-juremigi Can you share the connection string you use? And also, can you run If you are connecting to the default instance and don't have port number in registered SPNs, you are probably facing the same SPN issue. If so, I am afraid that there is no other workaround unless adding the port to the new SPNs. |
@cheenamalhotra, @karinazhou should I reopen this issue? Per @saurabh500's note #627 (comment) it says that the code checks for both with and without port number, but that wasn't our experience with the recent update. I had to change the SPN specifically to include port number. It didn't work without. |
@Code-DJ Please feel free to reopen it and we will look into this further. |
@karinazhou I am using named instance with port number: server\instance, port |
@mas-dse-juremigi For named instance, we have the fix for it ready which will be released soon. |
@Code-DJ One thing I would like to check with you. Have you tried with sqlcmd or isql with the same server name when you register the SPN without port number? You can test with the command like I would like to see the behavior of ODBC driver too. |
@karinazhou followed these steps:
BTW, before removing the SPN, I had tried the sqlcmd and was connected with a "1>" prompt. Also, not sure if sqlcmd and ODBC behind the scenes uses 2.1.1 as well. |
@Code-DJ Thank you for the experiment. sqlcmd uses ODBC driver which is separate from Microsoft.Data.SqlClient. If no port number is provided for TCP connection, they will append default 1433 to the SPN generation. |
@Code-DJ Would you mind giving this custom nuget a try which contains the change to allow default instance without port: It is expected to allow you to be connected successfully when there is only 1 SPN without port number registered. |
Hi @karinazhou that worked. Added 2.1.0-pull-3be647b.21057.9 to my project and debugged, it fetched data from SQL Server. Thanks! |
Can't authenticate with kerberos 2.1.1. Works fine with 2.0.1
Following is the error I get with Azure Data Studio where they upgraded their reference from older version to 2.1.1 in ADS 1.26.0:
The text was updated successfully, but these errors were encountered: