Cannot connect to Microsoft SQL server using Windows Authentication

Questions about Wine on Linux
Post Reply
jakthree
Newbie
Newbie
Posts: 2
Joined: Tue Jan 30, 2024 12:49 pm

Cannot connect to Microsoft SQL server using Windows Authentication

Post by jakthree »

Hi,
Ubuntu 22.04
Wine 8.0.2 - 32-bit prefix
Installed using winetricks
.NET 4.6.2
gdiplus
mdac28

I have winbind 4.15.13 installed. I am able to login to Ubuntu using my Windows domain account credentials.

I have a simple .NET Winforms Application which connects to a Microsoft SQL server and returns the date and time. I can choose to connect to SQL server by 'SQL Server Authentication' or by 'Windows Authentication'.
I am able to connect and retrieve date/time from the SQL server using a connection string that uses 'SQL Server Auth'.
"Connection Timeout=10;Data Source=MYSERVER;Initial Catalog=MyCat;Persist Security Info=True;Integrated Security=False;User ID=User;Password=MyPasswd"
I am NOT able to connect using a connection string that uses 'Windows Auth'.
"Connection Timeout=10;Data Source=MYSERVER;Initial Catalog=MyCat;Persist Security Info=True;Integrated Security=True"
The Test.exe app works as expected on a Windows 10 computer, but under wine I receive the following error.
WINEDEBUG=fixme-olepicture wine Test.exe
0098:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0098:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0098:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0098:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0024:fixme:ntdll:NtQuerySystemInformation info_class SYSTEM_PERFORMANCE_INFORMATION
0024:fixme:ntdll:EtwEventSetInformation (deadbeef, 2, 10003159, 28) stub
0024:fixme:ntdll:EtwEventSetInformation (deadbeef, 2, 014005ED, 28) stub
0024:fixme:heap:GetNumaHighestNodeNumber semi-stub: 0021FC50
0024:fixme:seh:WerRegisterRuntimeExceptionModule (L"C:\\windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscordacwks.dll", 013F0000) stub
010c:err:ole:CoGetContextToken apartment not initialised
0024:fixme:nls:get_dummy_preferred_ui_language (0x8 0x409 0021E694 00000000 0021E690) returning a dummy value (current locale)
0024:fixme:nls:get_dummy_preferred_ui_language (0x8 0x409 0021E694 00485F30 0021E690) returning a dummy value (current locale)
0024:fixme:nls:LCMapStringEx unsupported lparam 486248
0024:fixme:win:DisableProcessWindowsGhosting : stub
0068:fixme:imm:ImeSetActiveContext (00010026, 0): stub
0068:fixme:imm:ImmReleaseContext (00010020, 00010026): stub
0024:fixme:imm:ImeSetActiveContext (00020048, 1): stub
0024:fixme:imm:ImmReleaseContext (00010070, 00020048): stub
0024:fixme:ver:GetCurrentPackageId (0021BA48 00000000): stub
0024:err:ntdll:NtQueryInformationToken Unhandled token information class 11
011c:fixme:virtual:NtFlushProcessWriteBuffers stub
My test app has a try/catch that outputs the following
System.Runtime.InteropServices.COMException (0x80070001): Invalid function. (Exception from HRESULT: 0x80070001)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr token)
at System.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrent()
at System.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory)
at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Test.Form1.C1Button1_Click(Object sender, EventArgs e)
I understand that when using 'Integrated Security' that the login credentials sent to SQL server are gotten from the operating system. I think the problem is in System.Data.* and that wine cannot get the domain user/password credentials from Ubuntu.

Has anyone successfully used Windows Authentication to login into a MS SQL server?

Thank you,
jakthree
Newbie
Newbie
Posts: 2
Joined: Tue Jan 30, 2024 12:49 pm

Re: Cannot connect to Microsoft SQL server using Windows Authentication

Post by jakthree »

Hi,
More information.
When I created my first 32-bit prefix, when asked, I did not install mono because I knew that I was going to install .NET 4.6.2. For a test, I created a second 32-bit prefix and when asked, I installed mono. I did not install .NET. To my surprise, my simple test app does successfully connect to SQL using either Windows or SQL Server authentication. I turned on logging 'log successful and failed login' in my SQL server. When I check the SQL Sever Logs, it shows DOMAIN/user connection made using Integrated authentication. That leads me to believe that native Linux has everything installed and that part of something in .NET 4.6.2 replaced the part of mono that works.
My simple app works under mono. My complicated production app does not work under mono and requires .NET 4.6.2 which is way I have .NET installed.
What part of .NET is responsible for Integrated authentication?
I think I may be missing a dll or component.
After using winetricks to install .NET 4.6.2, is there another Windows dll or component I need to install that provides functionality for Integrated Auth to work?

Thank you,
Post Reply