184.108.40.206.8 Requesting a Lease on a File or a Directory
To request a lease, in addition to the parameters that are specified in section 220.127.116.11, the application provides a Boolean value indicating that a lease requires to be taken and a LeaseState value (as defined in section 18.104.22.168.8) that indicates the type of lease to be requested.<111>
The client MUST fail this request with STATUS_NOT_SUPPORTED in the following cases:
If Connection.Dialect is equal to "2.002".
If Connection.SupportsFileLeasing is FALSE.
If Connection.Dialect is equal to "2.100" and the open is on a directory.
The client MUST construct an SMB2 CREATE request as described in section 22.214.171.124, with a RequestedOplockLevel of SMB2_OPLOCK_LEVEL_LEASE.
If Connection.Dialect belongs to the SMB 3.x dialect family, the client MUST attach an SMB2_CREATE_REQUEST_LEASE_V2 create context to the request. The create context MUST be formatted as described in section 126.96.36.199.10 with the following values:
LeaseKey obtained from File.LeaseKey of the file or directory being opened.
The client MUST search the GlobalFileTable for the parent directory of the file being opened. (The name of the parent directory is obtained by removing the last component of the path.) If any entry is found, ParentLeaseKey is obtained from File.LeaseKey of that entry and SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET bit MUST be set in the Flags field.
LeaseState value provided by the application. If the filename to be opened, followed by a ":" colon character and a stream name, indicates a named stream as defined in [MS-FSCC] section 2.1.5, the client SHOULD clear the SMB2_LEASE_HANDLE_CACHING bit in the LeaseState field.
Epoch SHOULD be set to 0.
If Connection.Dialect is equal to "2.100", the client MUST attach an SMB2_CREATE_REQUEST_LEASE create context to the request. The create context MUST be formatted as described in section 188.8.131.52.8, with the LeaseState value provided by the application.