3.3.5.18 Receiving an SMB2 QUERY_DIRECTORY Request

When the server receives a request with an SMB2 header with a Command value equal to SMB2 QUERY_DIRECTORY, message handling proceeds as follows:

The server MUST locate the session, as specified in section 3.3.5.2.9.

The server MUST locate the tree connection, as specified in section 3.3.5.2.11.

Next, the server MUST locate the open for the directory to be queried by performing a lookup in the Session.OpenTable, using the FileId.Volatile of the request as the lookup key. If no open is found, or if Open.DurableFileId is not equal to FileId.Persistent, the server MUST fail the request with STATUS_FILE_CLOSED. Otherwise, the server MUST locate the Request in Connection.RequestList for which Request.MessageId matches the MessageId value in the SMB2 header, and set Request.Open to the Open.

If the open is not an open to a directory, the server MUST process the request as follows:

  • If SMB2_REOPEN is set in the Flags field of the SMB2 QUERY_DIRECTORY request, the request MUST be failed with an implementation-specific error code.<343>

  • Otherwise, the request MUST be failed with STATUS_INVALID_PARAMETER.

If OutputBufferLength is greater than Connection.MaxTransactSize, the server SHOULD<344> fail the request with STATUS_INVALID_PARAMETER.

If Connection.SupportsMultiCredit is TRUE, the server MUST validate CreditCharge based on OutputBufferLength, as specified in section 3.3.5.2.5. If the validation fails, it MUST fail the request with STATUS_INVALID_PARAMETER.

If Open.GrantedAccess does not include FILE_LIST_DIRECTORY, the operation MUST be failed with STATUS_ACCESS_DENIED.

The information classes supported are specified in [MS-FSCC] section 2.4. The supported classes for the query are:

  • FileDirectoryInformation

  • FileFullDirectoryInformation

  • FileBothDirectoryInformation

  • FileIdFullDirectoryInformation

  • FileIdBothDirectoryInformation

  • FileNamesInformation

If any other information class is specified in the FileInformationClass field of the SMB2 QUERY_DIRECTORY Request, the server MUST fail the operation with STATUS_INVALID_INFO_CLASS. If the information class requested is not supported by the server, the server MUST fail the request with STATUS_NOT_SUPPORTED.

If SMB2_RESTART_SCANS or SMB2_REOPEN is set in the Flags field of the SMB2 QUERY_DIRECTORY Request, the server MUST restart the scan with the search pattern specified, in an implementation-specific manner<345>.

If SMB2_RETURN_SINGLE_ENTRY is set in the Flags field of the request, the server MUST return only a single entry.

The server MUST invoke the query directory procedure from the underlying object store in an implementation-specific manner<346>.

An Underlying object store MAY<347> choose to support resuming enumerations by index number, if SMB2_INDEX_SPECIFIED is set in the Flags field and an index number is specified in the FileIndex field of the SMB2 QUERY_DIRECTORY Request.

If TreeConnect.Share.DoAccessBasedDirectoryEnumeration is TRUE and the object store supports security, the server MUST also exclude entries for which the user represented by Session.SecurityContext is not granted GENERIC_READ and FILE_LIST_DIRECTORY access.

Otherwise, the server MUST construct an SMB2_QUERY_DIRECTORY Response following the syntax specified in section 2.2.34, with the following values:

  • OutputBufferOffset MUST be set to the offset, in bytes, from the beginning of the SMB2 header where the enumeration data is being placed, the offset to Buffer[].

  • OutputBufferLength MUST be set to the length, in bytes, of the result of the enumeration.

  • The enumeration data MUST be copied into Buffer[].

The response MUST be sent to the client.

The status code returned by this operation MUST be one of those defined in [MS-ERREF]. Common status codes returned by this operation include:

  • STATUS_SUCCESS

  • STATUS_INSUFFICIENT_RESOURCES

  • STATUS_ACCESS_DENIED

  • STATUS_FILE_CLOSED

  • STATUS_NETWORK_NAME_DELETED

  • STATUS_USER_SESSION_DELETED

  • STATUS_NETWORK_SESSION_EXPIRED

  • STATUS_INVALID_PARAMETER

  • STATUS_INVALID_INFO_CLASS

  • STATUS_NO_SUCH_FILE

  • STATUS_CANCELLED

  • STATUS_NOT_SUPPORTED

  • STATUS_OBJECT_NAME_INVALID

  • STATUS_VOLUME_DISMOUNTED

  • STATUS_INVALID_INFO_CLASS

  • STATUS_FILE_CORRUPT_ERROR

  • STATUS_NO_MORE_FILES

Show: