<div class="content" name="NetrFileClose" uuid="190a7359-9d21-43d4-8298-5d5f5505951b"><p>The <a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a>
receives the NetrFileClose method in an RPC_REQUEST packet. In response, the
server MUST force an open resource instance (for example, file, device, or <a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_34f1dfa8-b1df-4d77-aa6e-d777422f9dca" data-linktype="relative-path">named pipe</a>) on the server
to close. This message can be used when an error prevents closure by any other
means.</p><dl>
<dd>
<div><pre> NET_API_STATUS NetrFileClose(
   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in] DWORD FileId
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>An <a href="5f8329ee-1965-4ea1-ad35-3b29fbb63232" data-linktype="relative-path">SRVSVC_HANDLE (section 2.2.1.1)</a>
pointer that identifies the server. The <a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a> MUST map this
structure to an RPC binding handle (see <a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a> sections 4.3.5
and 5.1.5.2). The server MUST ignore this parameter.</p><p><b>FileId: </b>Specifies the file identifier of the
open file, device, or pipe to close. </p><dl>
<dd>
<p><b>Note</b>  The <i>FileId</i> parameter
that is returned in a previous <a href="c5433da3-e2a5-4cdb-850b-0f9ce0795b8b" data-linktype="relative-path">NetrFileEnum</a> method call
is not guaranteed to be valid. Therefore, the NetrFileClose method is not
guaranteed to succeed based on the validity of the <i>FileId</i> parameter.</p>
</dd></dl><p><b>Return Values: </b>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 <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a>.
The most common error codes are listed in the following table.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 NERR_Success</td>
  <td>The client request succeeded.</td>
 </tr><tr>
  <td>0x00000005 ERROR_ACCESS_DENIED</td>
  <td>Access is denied.</td>
 </tr><tr>
  <td>0x0000090A NERR_FileIdNotFound</td>
  <td>There is no open file with the specified identification number.</td>
 </tr></tbody></table>
</dd></dl><p>This message can be used when an error prevents closure by
any other means.</p><p>The <i>FileId</i> parameter specifies the file identifier of
the <b>Open</b> in <b>FileList</b> to close. The value of the <i>FileId</i>
parameter MUST correspond to a <i>FileId</i> that is returned in a previous
NetrFileEnum message response by the server. The server MUST look up <b>Open</b>
in the <b>FileList</b> where <i>FileId</i> matches <b>Open.GlobalFileId</b>. If
no match is found, the server MUST return NERR_FileIdNotFound. If a match is
found, the server MUST close the <b>Open</b> by invoking an underlying server
event as specified in <a href="../ms-cifs/d416ff7c-c536-406e-a951-4f04b2fd1d2b" data-linktype="relative-path">[MS-CIFS]</a>
section <a href="../ms-cifs/9800e30c-24fe-4abb-998e-ed309a489841" data-linktype="relative-path">3.3.4.13</a>
or <a href="../ms-smb2/5606ad47-5ee0-437a-817e-70c366052962" data-linktype="relative-path">[MS-SMB2]</a>
section <a href="../ms-smb2/f6aca12a-02ca-4816-8ceb-84f78b36a65f" data-linktype="relative-path">3.3.4.17</a>,
providing <i>FileId</i> as the input parameter.</p><p>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.</p><p>The server SHOULD<a id="Appendix_A_Target_50"></a><a aria-label="Product behavior note 50" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_50" data-linktype="relative-path">&lt;50&gt;</a> 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<a id="Appendix_A_Target_51"></a><a aria-label="Product behavior note 51" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_51" data-linktype="relative-path">&lt;51&gt;</a> fail the call.</p></div>