3.1.4.4 NetrFileClose (Opnum 11)

The server receives the NetrFileClose method in an RPC_REQUEST packet. In response, the server MUST force an open resource instance (for example, file, device, or named pipe) on the server to close. This message can be used when an error prevents closure by any other means.

 NET_API_STATUS NetrFileClose(
   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in] DWORD FileId
 );

ServerName: An SRVSVC_HANDLE (section 2.2.1.1) pointer that identifies the server. The client MUST map this structure to an RPC binding handle (see [C706] sections 4.3.5 and 5.1.5.2). The server MUST ignore this parameter.

FileId: Specifies the file identifier of the open file, device, or pipe to close.

Note The FileId parameter that is returned in a previous NetrFileEnum method call is not guaranteed to be valid. Therefore, the NetrFileClose method is not guaranteed to succeed based on the validity of the FileId parameter.

Return Values: The method returns 0x00000000 (NERR_Success) to indicate success; otherwise, it returns a nonzero error code. The method can take any specific error code value, as specified in [MS-ERREF] section 2.2. The most common error codes are listed in the following table.

Return value/code

Description

0x00000000

NERR_Success

The client request succeeded.

0x00000005

ERROR_ACCESS_DENIED

Access is denied.

0x0000090A

NERR_FileIdNotFound

There is no open file with the specified identification number.

This message can be used when an error prevents closure by any other means.

The FileId parameter specifies the file identifier of the Open in FileList to close. The value of the FileId parameter MUST correspond to a FileId that is returned in a previous NetrFileEnum message response by the server. The server MUST look up Open in the FileList where FileId matches Open.GlobalFileId. If no match is found, the server MUST return NERR_FileIdNotFound. If a match is found, the server MUST close the Open by invoking an underlying server event as specified in [MS-CIFS] section 3.3.4.13 or [MS-SMB2] section 3.3.4.17, providing FileId as the input parameter.

If either CIFS or SMB2 servers return STATUS_SUCCESS, the server MUST return NERR_Success. Otherwise, the server MUST fail the call with a NERR_FileIdNotFound error code.

The server SHOULD<50> enforce security measures to verify that the caller has the required permissions to execute this routine. If the caller does not have the required credentials, the server SHOULD<51> fail the call.