Compartilhar via


2.1.5.10.8 FSCTL_FIND_FILES_BY_SID

The server provides:

  • Open: An Open of a DirectoryStream.

  • FindBySidData: An array of bytes containing a FIND_BY_SID_DATA structure as described in [MS-FSCC] section 2.3.15.

  • OutputBufferSize: The maximum number of bytes to return in OutputBuffer.

On completion, the object store MUST return:

  • Status: An NTSTATUS code that specifies the result.

  • OutputBuffer: An array of bytes that contains an 8-byte aligned array of FILE_NAME_INFORMATION ([MS-FSCC] section 2.1.7) structures. For more information, see [MS-FSCC] section 2.3.16.

  • BytesReturned: The number of bytes written to OutputBuffer.

This operation also uses the following local variables:

  • A list of Links (initialized to empty): MatchingLinks.

  • Unicode string: RelativeName.

  • 32-bit unsigned integers (initialized to zero): OutputBufferOffset, NameLength.

Support for this operation is optional. If the object store does not implement this functionality, the operation MUST be failed with STATUS_INVALID_DEVICE_REQUEST.<100>

Pseudocode for the operation is as follows:

  • If Open.Stream.StreamType is DataStream, the operation MUST be failed with STATUS_INVALID_PARAMETER.

  • If Open.HasManageVolumeAccess is FALSE and Open.HasBackupAccess is FALSE, the operation MUST be failed with STATUS_ACCESS_DENIED.

  • If Open.File.Volume.QuotaInformation is empty, the operation MUST succeed with BytesReturned set to zero and Status set to STATUS_NO_QUOTAS_FOR_ACCOUNT.

  • If OutputBufferSize is less than 8, the minimum size required to return a FILE_NAME_INFORMATION structure with trailing padding, the operation MUST be failed with STATUS_INVALID_USER_BUFFER.

  • If FindBySidData.Restart is TRUE, Open.FindBySidRestartIndex MUST be set to zero.

  • For each File in FindAllFiles(Open.File.Volume.RootDirectory):<101>

    • If File.SecurityDescriptor.OwnerSid matches FindBySidData.SID and File.FileNumber is greater than or equal to Open.FindBySidRestartIndex, insert the first element of File.LinkList into MatchingLinks.

  • EndFor

  • Sort MatchingLinks in ascending order by File.FileNumber.

  • For each Link in MatchingLinks:

    • Set RelativeName to BuildRelativeName(Link.File, Open.File).

    • If RelativeName is not empty (which means that Link represents Open.File or a descendant of it):

      • Strip off the leading backslash ("\") character from RelativeName.

      • Set NameLength to the length of RelativeName, in bytes.

      • If (OutputBufferLength - OutputBufferOffset) is less than BlockAlign(NameLength + 6, 8):

        • BytesReturned is set to OutputBufferOffset.

        • If OutputBufferOffset is not zero:

          • The operation returns with STATUS_SUCCESS.

        • Else:

          • The operation MUST be failed with STATUS_BUFFER_TOO_SMALL.

        • EndIf

      • EndIf

      • Construct a FILE_NAME_INFORMATION structure starting at OutputBuffer[OutputBufferOffset], with the first 4 bytes (the FileNameLength) set to NameLength, and the next NameLength bytes (the FileName) set to RelativeName.

      • OutputBufferOffset = OutputBufferOffset + BlockAlign(NameLength + 6, 8).

    • EndIf

    • Set Open.FindBySidRestartIndex to Link.File.FileNumber + 1.

  • EndFor

  • Upon successful completion of the operation, the object store MUST return:

    • BytesReturned set to OutputBufferOffset.

    • Status set to STATUS_SUCCESS.