20

First of all: everything you will read in this post happens only if Windows 10 April 2018 update is installed. No problem before installation and after update uninstallation.

After installing Windows 10 1803 update, all my VB program (VB6, .NET and WPF) running from network mapped drive or UNC path can't connect to SQL server, no problem if the same executable is placed and executed from local drive (tested on 2 pc in the same network):

  1. Remote SQL server, exe on local drive: OK
  2. Same remote SQL server, same exe on mapped network drive (with full read/write access): ERROR

This is the error (maybe not significat to solve this problem):

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).

Simple VB.NET code to reproduce the problem (place the code in a simple form with a button in the button_click event, set values to connect to the SQL server, compile, save the exe file on a network path and execute it):

Dim myConnectionString As String
Dim mySqlConnectionStringBuilder As New SqlConnectionStringBuilder()
mySqlConnectionStringBuilder.DataSource = myServer
mySqlConnectionStringBuilder.InitialCatalog = myDatabase
mySqlConnectionStringBuilder.UserID = myUtente
mySqlConnectionStringBuilder.Password = myPassword
myConnectionString = mySqlConnectionStringBuilder.ConnectionString

Dim mySqlConnection As New SqlConnection(myConnectionString)
mySqlConnection.Open()  <- error

Exception:

System.Data.SqlClient.SqlException (0x80131904): Si è verificato un errore di rete o specifico dell'istanza mentre si cercava di stabilire una connessione con SQL Server. Il server non è stato trovato o non è accessibile. Verificare che il nome dell'istanza sia corretto e che SQL Server sia configurato in modo da consentire connessioni remote. (provider: SQL Network Interfaces, error: 26 - Errore nell'individuazione del server/dell'istanza specificata)
   in System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
   in System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   in System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   in System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   in System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   in System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   in System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   in System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   in System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   in System.Data.SqlClient.SqlConnection.Open()
   in RiepilogoOreTimer.RiepilogoOreTimerWindow.ConnessioneOK()
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-1,State:0,Class:20

Any ideas?

Update: If I uninstall the April 2018 update the issue go away and the program works fine even if executed on a network drive, but this can't be the solution...

Update 08/05/2018: I noticed that April 2018 update brought some changes in security:

Windows 10, version 1803 provides additional protections:

  • New Attack surface reduction rules
  • Controlled folder access can now block disk sectors

Could it be the cause of the issue? I'm not a security manager so I can't say if this can cause my problem

Update 09/05/2018: I found this information in this post:

Windows 10 update 1803 does not open network connections on executables files on SMBv1 share (as Windows Server 2003)

but I don't know what SMBv1 is... somebody can help me?

Massimo Spinelli
  • 372
  • 2
  • 13
  • I have read four or five instances that is like yours and they indicate that it's blocking at the network level (if you opened a TCP socket somewhere it would fail as well, the error you received supports this as well). I would try something like Putty to test it. I would also look into the Windows firewall to see if it's causing the issue (e.g. could it be what's blocking the connection). – b.pell May 05 '18 at 02:49
  • I've already tried to disable the firewall but the problem persists. – Massimo Spinelli May 07 '18 at 07:09
  • 1
    I don't think that the connection is blocked at the network level, because the same pc can connect to the same server if the program is executed form a local drive and from SQL Management Studio. IMO, something changed with April 2018 update in the windows integrated SQL client – Massimo Spinelli May 07 '18 at 07:14
  • I can verify that this happens outside of VB6/VB.NET/WPF. We've had this happen in a niche language called DataFlex as well as Delphi. – flxkid May 08 '18 at 16:50
  • Try disabling windows defender and see if it helps? – Tarun Lalwani May 09 '18 at 06:29
  • @TarunLalwani Windows Defender is not enabled since we have Trend Micro antivirus and even if I close it, Windows Defender doesn't activate itself because security is managed by administrator – Massimo Spinelli May 09 '18 at 06:41
  • Then do one thing, download this tool [Process Explorer](https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer) and then compare the permissions of the process when it is run locally and when it is run throw network. Post the 2 images in your question. Just like https://i.stack.imgur.com/IIzfP.png – Tarun Lalwani May 09 '18 at 06:49
  • Good advice, but the permission of the process are identical. I compared each value of each tab in the two process properties windows and they are perfectly identical – Massimo Spinelli May 09 '18 at 07:52
  • First, in SQL Server's [Surface Area Configuration](https://docs.microsoft.com/en-us/sql/relational-databases/security/surface-area-configuration?view=sql-server-2017) check if the following options are enabled : `Local and remote connections` and `Using both TCP/IP and named pipes`. If NO: enable them and restart SQL Server. If YES, follow this [Troubleshooting Guide](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/troubleshoot-connecting-to-the-sql-server-database-engine?view=sql-server-2017) it will help you to find the right logs to better understand the issue – Thomas G May 09 '18 at 07:58
  • I already checked that option and are correct. Note that the same program can connect to the same SQL server in executed from a local path, so I think that the SQL server is correctly configurated – Massimo Spinelli May 09 '18 at 09:06

4 Answers4

16

Finally I found the problem: in the server with the shared folder, SMBv2 is disabled (I don't know why) so only SMBv1 is active; the same program executed from the same client in the same network but located on a server with SMBv2 enabled works fine.

So the problem is about SMBv1 share, deprecated starting from Windows 10 1803

Massimo Spinelli
  • 372
  • 2
  • 13
  • Thanks for sharing your answer! – Jeremiah Cooper May 09 '18 at 15:29
  • 1
    We have found this to be the case as well, but really we need to see the explanation from Microsoft on it also, Moving to SMBv2 does fix it, but nobody seems to be able to find anything from MS showing that network connections are blocked for executables started from SMBv1 shares. – flxkid May 09 '18 at 23:00
1

This blog gives a solution to this, which worked for us. Specifically look at the answer from "M.Hermann": Windows 10 1803 won't run ODBC SQL connected application from network

The below link seems to explain why SMBv1 is disabled: SMBv1 is not installed by default in Windows 10 Fall Creators Update and Windows Server, version 1709 and later versions

I'm not sure why this only seems to be a problem after 1803 though, since SMBv1 has been disabled since 1709.

Charl
  • 812
  • 1
  • 8
  • 22
  • Although this isn't an answer from MS, it certainly points to Windows Defender as the cause. We've already gotten confirmation that AVG being installed will also restore network access to executables started from an SMBv1 share. – flxkid May 15 '18 at 15:39
0

I have same problem with some application write in "Rad Studio 10.2"

I find a solution for me, i change my connection string by deleting the parameter "Network Library = dbmssocn"

I change this :

Provider=SQLOLEDB.1;Password=MyPassword;Persist Security Info=True;User ID=MyUser;Initial Catalog=MyDb;Data Source=MyServer;Network Library=dbmssocn;

To this :

Provider=SQLOLEDB.1;Password=MyPassword;Persist Security Info=True;User ID=MyUser;Initial Catalog=MyDb;Data Source=MyServer

Now all work fine !

Hadi
  • 36,233
  • 13
  • 65
  • 124
  • Unfortunately not for me... I didn't set that parameter in the connection string, btw I tried every option for that parameter but nothing changed – Massimo Spinelli May 09 '18 at 09:28
  • 1
    That parameter forces the use of TCP/IP. So by removing it, your app was able to use named pipes or shared memory to access the server. This solution will only work if your server is local. If the server is on the network where you have to use TCP/IP the problem will persist. – flxkid May 09 '18 at 22:57
-1

You are attempting to execute and untrusted executable (by default for any .exe on a network share). It is therefore restricted in what it can do.

Try right-clicking the exe and doing a 'run as administrator'.

You might also try looking into the local security policy.