3.2.5.5 Receiving an SMB2 TREE_CONNECT Response

If Connection.Dialect is "3.1.1" and the Status field in the SMB2 header of the response is STATUS_SMB_BAD_CLUSTER_DIALECT (0xC05D0001), the client MUST interpret the two bytes of ErrorContextData in the SMB2 ERROR Context response as the maximum dialect at which the client can connect to the cluster share. The client MUST connect to the share by passing the server-indicated dialect as the SpecifiedDialect and a newly generated Guid, as specified in section 3.2.4.2.

If Connection.Dialect is "3.1.1", SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER bit is set in the Flags field of the SMB2 TREE_CONNECT Request, the Status field in the SMB2 header of the response is STATUS_BAD_NETWORK_NAME, and the ErrorId in the SMB2 ERROR Context response is set to SMB2_ERROR_ID_SHARE_REDIRECT, the client MUST return the Share Redirect Error Context response to the calling application as specified in section 2.2.2.2.2.

If the Status field of the SMB2 header of the response indicates an error, the client MUST return the received status code to the calling application.

If the Status field of the SMB2 header of the response indicates success, the client MUST locate the session in the Connection.SessionTable using the SessionId in the SMB2 header of the response, and locate the request message in Connection.OutstandingRequests using the MessageId. The client MUST allocate a tree connect object and insert it into the Session.TreeConnectTable. The tree connect is initialized as follows:

  • TreeConnect.TreeConnectId MUST be set to the TreeId that is received in the SMB2 header of the response.

  • TreeConnect.Session MUST be set to the session that is looked up using SessionId from the SMB2 header of the response.

  • TreeConnect.IsDfsShare MUST be set to TRUE, if the SMB2_SHARE_CAP_DFS bit is set in the Capabilities field of the response.

  • TreeConnect.IsCAShare MUST be set to TRUE, if the SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY bit is set in the Capabilities field of the response.

  • TreeConnect.ShareName MUST be set to the share name, taken from the share path in the request message.

  • If Connection.Dialect belongs to the SMB 3.x dialect family, Connection.SupportsEncryption is TRUE, and if the SMB2_SHAREFLAG_ENCRYPT_DATA bit is set in the ShareFlags field of the response, the client MUST do the following:

    • TreeConnect.EncryptData MUST be set to TRUE.

If Connection.Dialect belongs to the SMB 3.x dialect family, the server MUST look up the Share object in ShareList where share path name sent in the Buffer field of SMB2 TREE_CONNECT request matches Share.PathName. If no Share object is found, the client MUST allocate a share object and insert into ShareList. The share object is initialized as follows:

  • Share.PathName MUST be set to the path name sent in the Buffer field of SMB2 TREE_CONNECT request message.

  • Share.EncryptData MUST be set to FALSE.

If Connection.Dialect belongs to the SMB 3.x dialect family, Connection.SupportsEncryption is TRUE, and if the SMB2_SHAREFLAG_ENCRYPT_DATA bit is set in the ShareFlags field of the response, the client MUST set Share.EncryptData to TRUE. Otherwise, the client MUST set Share.EncryptData to FALSE.

If Connection.Dialect is "3.1.1", Connection.CompressionIds is not empty, and the SMB2_SHAREFLAG_COMPRESS_DATA bit is set in the ShareFlags field of the response, the client MUST set ShareTreeConnect.CompressData to TRUE. Otherwise, the client MUST set TreeConnectShare.CompressData to FALSE.

If Connection.Dialect is "3.1.1" and the SMB2_SHAREFLAG_ISOLATED_TRANSPORT is set in the ShareFlags field of the response, the client MUST set Share.IsolatedTransport to TRUE. Otherwise, the client MUST set Share.IsolatedTransport to FALSE

The client MUST generate a handle for the TreeConnect and return the handle and share type received in the response to the application that initiated the connection to the share. The client sets the share type based on ShareType in the response.

Share type

ShareType

"Disk Share"

SMB2_SHARE_TYPE_DISK

0x01

"Named Pipe"

SMB2_SHARE_TYPE_PIPE

0x02

"Printer Share"

SMB2_SHARE_TYPE_PRINT

0x03

If Connection.Dialect belongs to the SMB 3.x dialect family and the Capabilities field in the response includes the SMB2_SHARE_CAP_SCALEOUT bit, the client MUST set TreeConnect.IsScaleoutShare to TRUE.

If Connection.Dialect belongs to the SMB 3.x dialect family and the Capabilities field in the response includes SMB2_SHARE_CAP_CLUSTER and SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY, the client MUST perform the following:

  • If Connection.Dialect is "3.0.2" or "3.1.1" and the Capabilities field in the response includes the SMB2_SHARE_CAP_ASYMMETRIC bit, the client MUST verify whether both of the following conditions are true:

    • Connection.SessionTable contains only one entry.

    • Session.TreeConnectTable contains only one entry.

      If either of the preceding conditions is FALSE, the client MUST perform the following:

      • Disconnect the tree connection as specified in section 3.2.4.22.

      • Establish a new transport connection by providing the ServerName and TransportIdentifier used in the previous connection, as specified in section 3.2.4.2.1.

      • Send an SMB2 NEGOTIATE request on the new connection, as specified in section 3.2.4.2.2.2. The client also provides a newly generated Guid to be used as ClientGuid.

      • If the SMB2 NEGOTIATE request is successful, the client MUST create a new session on the new connection by sending an SMB2 SESSION_SETUP request, as specified in section 3.2.4.2.3. The client provides the UserCredentials used in the previous connection.

      • If the SMB2 SESSION_SETUP request is successful, the client MUST send an SMB2 TREE_CONNECT request, as specified in section 3.2.4.2.4. The client provides the ShareName used in the previous connection.

      • If the SMB2 TREE_CONNECT request is successful, the client SHOULD invoke the event as specified in [MS-SWN] section 3.2.4.1 by providing Connection.ServerName as the Netname parameter and TreeConnect.ShareName as the ShareName parameter, and by setting the IsShareNameNotificationRequired parameter to TRUE.

  • Otherwise, the client SHOULD invoke the event as specified in [MS-SWN] section 3.2.4.1 by providing Connection.ServerName as Netname parameter.

If Connection.Dialect is not "3.1.1", MaxDialect belongs to the SMB 3.x dialect family, and RequireSecureNegotiate is TRUE, the client MUST validate the SMB2 NEGOTIATE messages originally sent on this connection by sending a signed VALIDATE_NEGOTIATE_INFO request as specified in section 2.2.31.4. The client MUST issue an SMB2 IOCTL Request as follows:

  • The SMB2 header MUST be initialized as follows:

    • The Command field is set to SMB2 IOCTL.

    • The MessageId field is set as specified in section 3.2.4.1.3.

    • The SessionId field is set to TreeConnect.Session.SessionId.

    • The TreeId field is set to TreeConnect.TreeConnectId.

  • The SMB2 IOCTL Request MUST be initialized as specified in section 2.2.31, with the exception of the following values:

    • The CtlCode field is set to FSCTL_VALIDATE_NEGOTIATE_INFO.

    • The FileId field is set to { 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF }.

    • The InputOffset field is set to the offset of the Buffer[], in bytes, from the beginning of the SMB2 header.

    • The InputCount field is set to the size, in bytes, of the VALIDATE_NEGOTIATE_INFO request structure that is constructed following the syntax specified in section 2.2.31.4.

    • The VALIDATE_NEGOTIATE_INFO request structure is constructed as follows and copied into the request at InputOffset bytes from the beginning of the SMB2 header:

      • Capabilities is set to Connection.ClientCapabilities.

      • Guid is set to the Connection.ClientGuid value.

      • SecurityMode is set to Connection.ClientSecurityMode.

      • Dialects array SHOULD<184> be set to Connection.OfferedDialects.

      • Set DialectCount to the number of dialects in Dialects array.

    • The OutputOffset field offset to the Buffer[], in bytes, from the beginning of the SMB2 header.

    • The OutputCount field is set to 0.

    • The MaxInputResponse field is set to 0.

    • The MaxOutputResponse field is set to the size of the VALIDATE_NEGOTIATE_INFO response structure as defined in section 2.2.32.6.

    • The value of the Flags field is set to SMB2_0_IOCTL_IS_FSCTL.

  • The request MUST be signed as specified in section 3.1.4.1, MUST be sent to the server, and the response from the server MUST be handled as specified in section 3.2.5.14.12.

If Connection.Dialect belongs to the SMB 3.x dialect family and Connection.SupportsMultiChannel is TRUE, Connection.Server.AddressList is empty, and both Session.IsGuest and Session.IsAnonymous are FALSE, the client MUST query the network interfaces on the server, as specified in section 3.2.4.20.10, by passing the TreeConnect from Session.TreeConnectTable.