Bug 11122 - System.InvalidOperationException : Refusing to use legacy-mode LM/NTLM authentication unless explicitly enabled using DefaultAuthLevel.
Summary: System.InvalidOperationException : Refusing to use legacy-mode LM/NTLM authen...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-03-13 12:40 UTC by james lewis
Modified: 2017-09-01 09:29 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description james lewis 2013-03-13 12:40:23 UTC
When querying SQL server 2008 r2 with a function that returns the sql_variant type (e.g. DATABASEPROPERTYEX[1] or ASSEMBLYPROPERTY[2]) the following exception is thrown: 

System.InvalidOperationException : Refusing to use legacy-mode LM/NTLM authentication unless explicitly enabled using DefaultAuthLevel.

Stack trace:

at Mono.Security.Protocol.Ntlm.Type3Message..ctor () [0x00044] in /root/7digital-mono/mono-3.0.3/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs:76 at Mono.Data.Tds.Protocol.Tds.ProcessAuthentication () [0x00021] in /root/7digital-mono/mono-3.0.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1466 at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x0014c] in /root/7digital-mono/mono-3.0.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1821 at Mono.Data.Tds.Protocol.Tds.NextResult () [0x0004a] in /root/7digital-mono/mono-3.0.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:641 at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00005] in /root/7digital-mono/mono-3.0.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:714 at Mono.Data.Tds.Protocol.Tds70.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x005b5] in /root/7digital-mono/mono-3.0.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs:372 at Mono.Data.Tds.Protocol.Tds80.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x00000] in /root/7digital-mono/mono-3.0.3/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds80.cs:75 at System.Data.SqlClient.SqlConnection.Open () [0x001a9] in /root/7digital-mono/mono-3.0.3/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs:566


[1] http://msdn.microsoft.com/en-us/library/ms186823.aspx
[2] http://msdn.microsoft.com/en-us/library/ms188750.aspx
Comment 1 Andres G. Aragoneses 2013-03-13 13:27:57 UTC
In mono 3.0.0 the exception is different:

System.Data.SqlClient.SqlException : Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
at System.Data.SqlClient.SqlConnection.ErrorHandler (System.Object sender, Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x00032] in /home/lockerteam/mono-3.0.0/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs:309
at Mono.Data.Tds.Protocol.Tds.OnTdsErrorMessage (Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e) [0x0000b] in /home/lockerteam/mono-3.0.0/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1698
at Mono.Data.Tds.Protocol.Tds.ProcessMessage (TdsPacketSubType subType) [0x000ef] in /home/lockerteam/mono-3.0.0/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1738
at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x0012a] in /home/lockerteam/mono-3.0.0/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1790
at Mono.Data.Tds.Protocol.Tds.NextResult () [0x0004a] in /home/lockerteam/mono-3.0.0/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:619
at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00005] in /home/lockerteam/mono-3.0.0/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:692
at Mono.Data.Tds.Protocol.Tds70.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x005b5] in /home/lockerteam/mono-3.0.0/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs:372
at Mono.Data.Tds.Protocol.Tds80.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x00000] in /home/lockerteam/mono-3.0.0/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds80.cs:75
at System.Data.SqlClient.SqlConnection.Open () [0x001a2] in /home/lockerteam/mono-3.0.0/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs:557
Comment 2 james lewis 2013-03-13 14:32:40 UTC
In mono 3.0.7 it is the same as 3.0.3:

System.InvalidOperationException : Refusing to use legacy-mode LM/NTLM authentication unless explicitly enabled using DefaultAuthLevel.
at Mono.Security.Protocol.Ntlm.Type3Message..ctor () [0x00044] in /home/lockerteam/307/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs:76
at Mono.Data.Tds.Protocol.Tds.ProcessAuthentication () [0x00021] in /home/lockerteam/307/mono/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1466
at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x0014c] in /home/lockerteam/307/mono/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:1821
at Mono.Data.Tds.Protocol.Tds.NextResult () [0x0004a] in /home/lockerteam/307/mono/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:641
at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00005] in /home/lockerteam/307/mono/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs:714
at Mono.Data.Tds.Protocol.Tds70.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x005b5] in /home/lockerteam/307/mono/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs:390
at Mono.Data.Tds.Protocol.Tds80.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x00000] in /home/lockerteam/307/mono/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds80.cs:87
at System.Data.SqlClient.SqlConnection.Open () [0x001a9] in /home/lockerteam/307/mono/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs:566
Comment 3 james lewis 2013-03-13 15:09:46 UTC
Hey Martin, we believe this is kind of related to changes you have done recently, such as:

https://github.com/mono/mono/commit/45745e5123267e8530b87b8dada9a89c6269b383

and 

https://github.com/mono/mono/commit/10fa0cd33877de58176384cc3431d41af2c9a714


We have submitted a pull request that partially fixes this: at least makes it fail as it was failing in Mono 3.0.0. It is here:

https://github.com/mono/mono/pull/599


Can you review it and advice on the next steps to fix the exception that we mention in comment#1?

Thanks in advance.
Comment 4 Martin Baulig 2013-03-13 17:35:59 UTC
Looks good, merged it :-)
Comment 5 Veerapuram Varadhan 2013-03-21 12:22:24 UTC
Does it work in general except for queries involving these (e.g. DATABASEPROPERTYEX or ASSEMBLYPROPERTY) ?

I mean.. connecting to the server and performing other queries, does it work?
Comment 6 Andres G. Aragoneses 2013-03-21 12:25:53 UTC
Sorry Varadhan, I should have sent an update: we discovered that this was happening because we were using "Trusted Connection" in the connection string, then it is normal that it doesn't work from a Linux box which doesn't have ActiveDirectory credentials...

So we can say that there was no bug, other than the one we fixed in this pull request: https://github.com/mono/mono/pull/599 (with this change, at least it will throw the invalid login exception instead of the weird "Refusing to use legacy-mode LM/NTLM authentication" error).

So then, can you guys close this as FIXED? I apparently don't have rights to do so.