3.2.4.2.4 Connecting to the Share
To connect to a share, the client MUST follow the steps outlined below.
The client MUST construct an SMB2 TREE_CONNECT Request using the syntax specified in section 2.2.9. The SMB2 header MUST be initialized as follows:
The Command field is set to SMB2 TREE_CONNECT.
The MessageId field is set as specified in section 3.2.4.1.3.
The SessionId field is set to Session.SessionId of the session that was identified in section 3.2.4.2 or established as a result of processing section 3.2.4.2.3.
The SMB2 TREE_CONNECT Request MUST be initialized as follows:
If Connection.Dialect is "3.1.1" and the optional RemotedIdentity parameter is true, the client MUST add a tree connect request extension in the Buffer field as specified in section 2.2.9.1, and MUST set the SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT bit in the Flags field. The target share path, including server name, in the format "\\server\share", MUST be copied into the PathName field of the tree connection request extension, as specified in section 2.2.9.2.1.
The client MUST construct a remoted identity tree connect context, as specified in section 2.2.9.2.1, by setting the User, UserName, Domain, Groups, RestrictedGroups, Privileges, PrimaryGroup, Owner, DefaultDacl, DeviceGroups, UserClaims and DeviceClaims in the SMB2_REMOTED_IDENTITY_TREE_CONNECT context, to the values specified by the application.
Otherwise, the target share path, including server name, in the format "\\server\share", is copied into the Buffer field of the request. PathOffset and PathLength MUST be set to describe the location and length of the target share path in the request.If Connection.Dialect is "3.1.1" and the optional ClusterReconnect parameter is true, the client MUST set the SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT bit in the Flags field.
If Connection.Dialect is "3.1.1", the optional SyncRedirect parameter is true, and the share previously connected includes the SMB2_SHARE_CAP_ASYMMETRIC capability, the client SHOULD<141> set the SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER bit in the Flags field.
This request MUST be sent to the server. The response from the server MUST be processed as described in section 3.2.5.5.