SMB2

SMB2

Postby Otto » Tue Jun 14, 2011 8:27 am

Does someone know i fit is possible to detect from a client if on the fileserver SMB2 is on or off?

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: SMB2

Postby driessen » Tue Jun 14, 2011 10:46 am

Otto,

Here are some links concerning the problem you mentioned :

http://www.caseware.com/support/caseknowledge/kb-271
http://www.petri.co.il/how-to-disable-smb-2-on-windows-vista-or-server-2008.htm
http://lists.harbour-project.org/pipermail/harbour/2010-March/033144.html
http://lists.harbour-project.org/pipermail/harbour/2010-April/035609.html

I hope you can find a solution in one of those.

With SMB 2.0 enabled on a Windows 2008 Server and a Windows 7 workstation, index-files are often getting corrupt (CDX). By disabling SMB 2.0, this problem vanishes.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: SMB2

Postby Otto » Tue Jun 14, 2011 12:58 pm

Thank you Michel.
The links only discript how to switch off SMB2.
But I would like if it is possible to detect that if connection to a specific server is happening with SMB2 ?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: SMB2

Postby Otto » Wed Jun 15, 2011 7:05 am

I found a good description of the SMB2 problem in
http://stackoverflow.com/questions/5464 ... indows-vis
Best regards,
Otto

My question is a slight variation on the question What is the best way to test whether a file exists on Windows?, with some specific caveats. Specifically, the data is located on a mapped drive, and the SMB 2.0 protocol is used. (By definition, this requires that the drive be mapped from a Vista machine to either a Vista or Server 2008 machine.)

The problem with the answers posted in reply to the above question is that SMB 2.0 caches a bunch of metadata, including filenames in a given directory. As a result, if you are testing for the existence of a file that was just created, then functions _access, access, GetFileAttributes, and CreateFile (and perhaps others) will all use cached information to answer the question "does this file exist?". If the file was very recently created by another user, the cache indicates that the file is not present, despite the fact that it does indeed exist. I've set up test environments to test this, and I can confirm that no SMB2 traffic is generated by the client for several seconds [presumably the cache expires every 5 seconds or so].

Has anyone else seen this? (If so, did you find a workaround other than adding a delay/retry?) Does anyone know of any API similar to the above that can check for file existence without using the SMB cache? Or, better yet, does anyone know of a Windows API that will simply dump the cached SMB metadata?
Why do you need to do this exactly? Why is it a problem if the cache gives the "wrong" answer? What depends on it "working"? – John Zwinck Feb 25 '09 at 1:49
Well, without going into too much detail, a user initiates a process that causes a new file to be created in the share. If that file is created by another machine, the "wrong" answer means that the user can't open the file, because SMB2 won't send the open request if the file "doesn't exist". – Jedidiah Thomet Feb 25 '09 at 18:16
I think you should go into more detail. I imagine there is some other aspect of the design that could be improved to provide a satisfactory user experience. – John Zwinck Feb 26 '09 at 4:19
While not a programmatic solution, I found an effective workaround (with the help of Microsoft support). I wanted to post the workaround here in case anyone else is as frustrated by this as I have been. Because this behavior is a "feature" of SMB2, Microsoft has provided the following registry entries to override the default metadata cache lifetime:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\FileInfoCacheLifetime HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\FileNotFoundCacheLifetime HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\DirectoryCacheLifetime Each of these are DWORD values, which can be set according to your needs. (Setting these to 0 on the SMB2 client was effective in resolving my issue.)
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: SMB2

Postby Maurizio » Wed Jun 15, 2011 8:03 am

Ciao Otto

http://social.msdn.microsoft.com/Forums ... 0138a4cd7c

Regards Maurizio

Please note that we will not publish any knowledge base content on the new settings until 2008R2 & Windows 7 are released; so my earlier comment was a bit premature. The information on the new settings is all that is available at this time.

Thanks for your patience!

Regards,
Bill Wesse


==============================================================================
Registry values

All listed settings are in the following registry location:

Key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanWorkStation\Parameters

Value type: REG_*
Value name: <name of value>
Default: <value if note present>

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: AllowGuestAuthWhenSigningRequired
Default: FALSE

Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876

When a Server Message Block (SMB) version 1 client establishes a non-guest session or a non-anonymous session with a server, the client enables security signatures for the server. Later sessions then inherit the security signature sequence that is already established.

To improve security, Windows Server 2008 and Windows Vista SP1 prevent server authenticated connections from being maliciously downgraded to a guest session or to an anonymous session. However, this improved security does not address the scenario that is described in the "Symptoms" section (Event ID: 1058).

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: FileInfoCacheLifetime
Default: 10 (seconds)

Used for increasing network file system performance.
The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: FileNotFoundCacheLifetime
Default: 5 (seconds)

Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: DirectoryCacheLifetime
Default: 10 (seconds)

Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: DisableBandwidthThrottling
Default: FALSE

Performance Tuning Guidelines for Windows Server 2008.
http://go.microsoft.com/fwlink/?LinkId=121171

The default is 0. This setting is available starting with Windows Server 2008 SP2. By default, the SMB redirector throttles throughput across high-latency network connections in some cases to avoid network-related timeouts. Setting this registry value to 1 disables this throttling, enabling higher file transfer throughput over high-latency network connections.

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: DisableByteRangeLockingOnReadOnlyFiles
Default: FALSE

How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: ExtendedSessTimeout
Default: 1000 (seconds)

Value type: REG_MULTI_SZ
Value name: ServersWithExtendedSessTimeout
Default: <null>

May be useful in high latency networks.

Controls the time-out period that the client uses when sending requests to a server listed in ServersWithExtendedSessTimeout. The default is value is 1000 (or 16.67 minutes). You can increase this value on all Windows 2003 and later systems.

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: NoDeleteOnClose
Default: FALSE

You cannot modify or delete files on an OS/2 Warp 4-based server that uses the HPFS file system
http://support.microsoft.com/kb/813586

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: ScavengerTimeLimit
Default: 0 (seconds)

How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041

You may experience delays of between 10 and 60 seconds when you use UNC paths to access files that are stored on a remote SMB server on a multihomed Windows Server 2003-based computer
http://support.microsoft.com/kb/890553

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnableCachingOnWriteOnlyOpens
Default: FALSE

Write only files are not cacheable; note that this setting is not recommended due to possible side effects.
Use SetFilePointer(...) and SetEndOfFile(...) instead.

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnableDownLevelLogOff
Default: FALSE

Net3101 Error on OS/2 Server Because of SessionSetup SMB
http://support.microsoft.com/kb/323582

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnablePlainTextPassword
Default: FALSE

Unencrypted Passwords May Cause SP3 to Fail to Connect to SMB Servers
http://support.microsoft.com/kb/166730

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnableSecuritySignature
Default: TRUE

Value type: REG_DWORD
Value name: RequireSecuritySignature
Default: FALSE

Overview of Server Message Block signing
http://support.microsoft.com/kb/887429

Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876

Server Message Block communication between a client-side SMB component and a server-side SMB component is not completed if the SMB signing settings are mismatched in Group Policy or in the registry
http://support.microsoft.com/kb/916846

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: OffLineFileTimeoutIntervalInSeconds
Default: 1000

User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: SMB2

Postby dutch » Thu Jun 16, 2011 7:02 am

Dear Maurizio,

If I need to disable SMB2. Will I be disable on Server or Client side?

Regards,
Dutch
Maurizio wrote:Ciao Otto

http://social.msdn.microsoft.com/Forums ... 0138a4cd7c

Regards Maurizio

Please note that we will not publish any knowledge base content on the new settings until 2008R2 & Windows 7 are released; so my earlier comment was a bit premature. The information on the new settings is all that is available at this time.

Thanks for your patience!

Regards,
Bill Wesse


==============================================================================
Registry values

All listed settings are in the following registry location:

Key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanWorkStation\Parameters

Value type: REG_*
Value name: <name of value>
Default: <value if note present>

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: AllowGuestAuthWhenSigningRequired
Default: FALSE

Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876

When a Server Message Block (SMB) version 1 client establishes a non-guest session or a non-anonymous session with a server, the client enables security signatures for the server. Later sessions then inherit the security signature sequence that is already established.

To improve security, Windows Server 2008 and Windows Vista SP1 prevent server authenticated connections from being maliciously downgraded to a guest session or to an anonymous session. However, this improved security does not address the scenario that is described in the "Symptoms" section (Event ID: 1058).

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: FileInfoCacheLifetime
Default: 10 (seconds)

Used for increasing network file system performance.
The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: FileNotFoundCacheLifetime
Default: 5 (seconds)

Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: DirectoryCacheLifetime
Default: 10 (seconds)

Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.

==============================================================================
Vista, 2008, ...

Value type: REG_DWORD
Value name: DisableBandwidthThrottling
Default: FALSE

Performance Tuning Guidelines for Windows Server 2008.
http://go.microsoft.com/fwlink/?LinkId=121171

The default is 0. This setting is available starting with Windows Server 2008 SP2. By default, the SMB redirector throttles throughput across high-latency network connections in some cases to avoid network-related timeouts. Setting this registry value to 1 disables this throttling, enabling higher file transfer throughput over high-latency network connections.

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: DisableByteRangeLockingOnReadOnlyFiles
Default: FALSE

How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: ExtendedSessTimeout
Default: 1000 (seconds)

Value type: REG_MULTI_SZ
Value name: ServersWithExtendedSessTimeout
Default: <null>

May be useful in high latency networks.

Controls the time-out period that the client uses when sending requests to a server listed in ServersWithExtendedSessTimeout. The default is value is 1000 (or 16.67 minutes). You can increase this value on all Windows 2003 and later systems.

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: NoDeleteOnClose
Default: FALSE

You cannot modify or delete files on an OS/2 Warp 4-based server that uses the HPFS file system
http://support.microsoft.com/kb/813586

==============================================================================
Windows 2003, ...

Value type: REG_DWORD
Value name: ScavengerTimeLimit
Default: 0 (seconds)

How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041

You may experience delays of between 10 and 60 seconds when you use UNC paths to access files that are stored on a remote SMB server on a multihomed Windows Server 2003-based computer
http://support.microsoft.com/kb/890553

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnableCachingOnWriteOnlyOpens
Default: FALSE

Write only files are not cacheable; note that this setting is not recommended due to possible side effects.
Use SetFilePointer(...) and SetEndOfFile(...) instead.

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnableDownLevelLogOff
Default: FALSE

Net3101 Error on OS/2 Server Because of SessionSetup SMB
http://support.microsoft.com/kb/323582

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnablePlainTextPassword
Default: FALSE

Unencrypted Passwords May Cause SP3 to Fail to Connect to SMB Servers
http://support.microsoft.com/kb/166730

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: EnableSecuritySignature
Default: TRUE

Value type: REG_DWORD
Value name: RequireSecuritySignature
Default: FALSE

Overview of Server Message Block signing
http://support.microsoft.com/kb/887429

Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876

Server Message Block communication between a client-side SMB component and a server-side SMB component is not completed if the SMB signing settings are mismatched in Group Policy or in the registry
http://support.microsoft.com/kb/916846

==============================================================================
Windows 2000, ...

Value type: REG_DWORD
Value name: OffLineFileTimeoutIntervalInSeconds
Default: 1000

Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: SMB2

Postby driessen » Thu Jun 16, 2011 7:42 am

I have always disabled SMB2 on the server and on the workstations.
I never noticed that index problem again.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: SMB2

Postby dutch » Thu Jun 16, 2011 9:02 am

Dear driessen,

driessen wrote:I have always disabled SMB2 on the server and on the workstations.
I never noticed that index problem again.


Thank you so much,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: SMB2

Postby Horizon » Fri Oct 07, 2011 2:51 pm

Hi Otto,

Have you found to detect that is Smb2 enabled? Somebody is talked about the function WIN_OSNETREGOK() in Harbour but I could not found it.

Thanks,
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: SMB2

Postby dutch » Fri Oct 07, 2011 4:53 pm

This code is fixed SMB2 (Index problem for Windows Server2008 and WIndows7) for me. Run at server and client, then restart all.
Code: Select all  Expand view
#include "FiveWin.Ch"

#define  HKEY_LOCAL_MACHINE      2147483650

//---------------------------------------------------------------------------//

function Main()

   LOCAL oReg, cName, uVar

   oReg := TReg32():Create( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters" )

   // Call Set with an empty string to access the default key

   oReg:Set( "FileInfoCacheLifetime", 0 )
   oReg:Set( "FileNotFoundCacheLifetime", 0 )
   oReg:Set( "DirectoryCacheLifetime", 0 )

   oReg:Close()

   oReg := TReg32():Create( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\LanmanServer\Parameters" )

   // Call Set with an empty string to access the default key

   oReg:Set( "Smb2", 0 )

   oReg:Close()

   MsgInfo( "Windows registry updated!" )

return nil
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: SMB2

Postby Horizon » Fri Oct 07, 2011 6:20 pm

Thank you very much dutch,

I will try it soon.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: SMB2

Postby IBTC » Tue Nov 06, 2012 4:17 pm

How is it with Windows 8?
Best Regards,
Ruediger Alich

---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
User avatar
IBTC
 
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany

Re: SMB2

Postby omarelunico » Fri Nov 15, 2013 11:15 pm

I think the solution is modify the registry REGEDIT.

sc config lanmanworkstation depend= bowser/mrxsmb10/nsi
This sets the following registry value:
HKLM\System\CurrentControlSet\services\LanmanWorkstation\DependOnService
Type: REG_MULTI_SZ
Data: bowser, mrxsmb10, nsi



sc config mrxsmb20 start= disabled

This sets the following registry value:
HKLM\System\CurrentControlSet\services\mrxsmb20\Start
Type: REG_DWORD
Data: 4
User avatar
omarelunico
 
Posts: 33
Joined: Sun May 14, 2006 7:31 am
Location: Lima - Perú

Re: SMB2

Postby Antonio Linares » Thu May 29, 2014 3:15 am

Michel,

driessen wrote:I have always disabled SMB2 on the server and on the workstations.
I never noticed that index problem again.


Did you disable it using the same code as Dutch ? Or in a different way ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 32 guests