3.2.4.4 Re-establishing a Durable Open

When an application requests an operation on an open, where Open.Durable is TRUE, that existed on a now-disconnected connection, the client MUST perform the following:

The client MUST attempt to connect to the target share, as specified in section 3.2.4.2, by obtaining the name of the server and the name of the share to connect to from the Open.FileName. If this attempt fails, the client MUST fail the re-establishment attempt. If this attempt succeeds, the client MUST construct an SMB2 CREATE Request according to the syntax specified in section 2.2.13. The SMB2 header MUST be initialized as follows:

  • The Command field is set to SMB2 CREATE.

  • 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 CREATE Request MUST be initialized as follows:

  • The SecurityFlags field is set to 0.

  • The RequestedOplockLevel field is set to Open.OplockLevel.

  • The ImpersonationLevel field is set to 0.

  • The DesiredAccess field is set to Open.DesiredAccess.

  • The FileAttributes field is set to Open.FileAttributes.

  • The ShareAccess field is set to Open.ShareMode.

  • The CreateDisposition field is set to Open.CreateDisposition.

  • The CreateOptions field is set to Open.CreateOptions.

  • The client copies the relative path into Buffer and sets NameLength to the length, in bytes, of the relative path, and NameOffset to the offset, in bytes, to the relative path from the beginning of the SMB2 header.

  • If Connection.Dialect is "2.1", an SMB2_CREATE_DURABLE_HANDLE_RECONNECT create context is constructed according to the syntax specified in section 2.2.13.2.4. The data value is set to Open.FileId, and the create context is appended to the create request.

  • If Connection.Dialect belongs to the SMB 3.x dialect family, an SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context is constructed according to the syntax specified in section 2.2.13.2.12. The FileId value is set to Open.FileId, CreateGuid is set to Open.CreateGuid, and the create context is appended to the create request. If Open.IsPersistent is TRUE, the client MUST set SMB2_DHANDLE_FLAG_PERSISTENT bit in the Flags field.

  • If Connection.Dialect is not "2.0.2", and the original open was performed by using a lease as specified in section 3.2.4.3.8, as indicated by Open.OplockLevel set to SMB2_OPLOCK_LEVEL_LEASE, the client MUST re-request the lease as specified in section 3.2.4.3.8 with the exception of the following values:

    • The LeaseState field MUST be set to File.LeaseState of the file being opened.

    • If Connection.Dialect belongs to the SMB 3.x dialect family, the Epoch field MUST be set to File.LeaseEpoch of the file being opened.

This request MUST be sent to the server.