<div class="content" name="NetrUseDel" uuid="8964c5ef-789d-4e6b-8c77-f0b30337fdb7"><p>The <b>NetrUseDel</b> function terminates a connection from
the workstation server to a shared resource on an SMB server. The server SHOULD
NOT<a id="Appendix_A_Target_49"></a><a aria-label="Product behavior note 49" href="def80006-2495-4571-8a93-1668e0f8af31#Appendix_A_49" data-linktype="relative-path">&lt;49&gt;</a> allow this method to be invoked
remotely and SHOULD return ERROR_CALL_NOT_IMPLEMENTED.</p><dl>
<dd>
<div><pre> unsigned long NetrUseDel(
   [in, string, unique] WKSSVC_IMPERSONATE_HANDLE ServerName,
   [in, string] wchar_t* UseName,
   [in] unsigned long ForceLevel
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>A <b>WKSSVC_IMPERSONATE_HANDLE</b> structure
(section <a href="2427e140-22b3-45f8-9e12-1b3593308e46" data-linktype="relative-path">2.2.2.2</a>) that
identifies the <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server (2)</a>.
The <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a> MUST map this
structure to an <a href="3acf0e02-9bbd-4ce0-a7a0-586bc72d3ef4#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a>
binding handle (<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>UseName: </b>A pointer to a string that specifies
the local device name or shared resource name for which to return information.</p><p><b>ForceLevel: </b>The level of force to use in
deleting the connection. This parameter MUST be one of the following values;
otherwise, the server MUST fail the call with an ERROR_INVALID_LEVEL error
code.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value/code</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>USE_NOFORCE 0x00000000</td>
  <td>Do not disconnect the connection if open files exist on the connection.</td>
 </tr><tr>
  <td>USE_FORCE 0x00000001</td>
  <td>Same as 0x00000000 (USE_NOFORCE); do not disconnect the connection if open files exist on the connection.</td>
 </tr><tr>
  <td>USE_LOTS_OF_FORCE 0x00000002</td>
  <td>Close any open files and disconnect the connection.</td>
 </tr></tbody></table>
</dd></dl><p><b>Return Values: </b>When the message processing
result meets the description in the right-hand column of the following table,
this method MUST return one of the following values (<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>).</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value/code</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>NERR_Success 0x00000000</td>
  <td>The operation completed successfully.</td>
 </tr><tr>
  <td>ERROR_ACCESS_DENIED 0x00000005</td>
  <td>Access is denied.</td>
 </tr><tr>
  <td>ERROR_INVALID_PARAMETER 0x00000057</td>
  <td>One of the function parameters is not valid.</td>
 </tr><tr>
  <td>ERROR_INVALID_LEVEL 0x0000007C</td>
  <td>The force level is invalid.</td>
 </tr><tr>
  <td>ERROR_DEVICE_IN_USE 0x00002404</td>
  <td>The connection handle is in use and cannot be disconnected.</td>
 </tr><tr>
  <td>ERROR_REDIR_PAUSED 0x00000048</td>
  <td>Remote access to the specified printer or serial communications device has been paused.</td>
 </tr></tbody></table>
</dd></dl><p>The server SHOULD<a id="Appendix_A_Target_50"></a><a aria-label="Product behavior note 50" href="def80006-2495-4571-8a93-1668e0f8af31#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 server enforces security measures and the caller
does not have the required credentials, the server MUST fail the call with
ERROR_ACCESS_DENIED. Specifications for determining the identity of the caller
for the purpose of performing an access check are in <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>
section <a href="../ms-rpce/0e5b0e1c-0ba5-4342-bc36-30c66a9d07fd" data-linktype="relative-path">3.3.3.1.3</a>.</p><p>The <i>UseName</i> parameter specifies the local device name
or shared resource name for which to delete a tree connection. The server MUST
canonicalize <i>UseName</i> (<a href="../ms-srvs/accf23b0-0f57-441c-9185-43041f1b0ee9" data-linktype="relative-path">[MS-SRVS]</a>
section <a href="../ms-srvs/e79aaff9-ba49-4548-8cc6-7041a7fcf907" data-linktype="relative-path">3.1.4.33</a>).
This MUST be a nonempty, null-terminated UTF-16 string; otherwise, the server MUST
fail the call with an ERROR_INVALID_PARAMETER error code.</p><p>The server MUST ensure that the remaining steps are executed
atomically with respect to other callers performing queries or updates to the <b>UseTable</b>
and <b>Connection</b> tables.</p><p>The server MUST invoke the event to impersonate the client
([MS-RPCE] section <a href="../ms-rpce/a996aa17-8e04-4a25-806a-a3c724230e12" data-linktype="relative-path">3.3.3.4.3.1</a>),
passing in NULL as input parameter. If this event fails, the server MUST return
an error. If the event returns UserToken, the server MUST look in <b>UseTable</b>
for the user where <b>UseEntry.UserToken</b> matches UserToken. If no match is
found, the server MUST fail the call with a NERR_UseNotFound error code.</p><p>If a match is found and <i>UseName</i> is a UNC path type,
the server MUST locate a <b>UseEntry.ConnectionTable</b> where <i>UseName</i>
matches <b>Connection.remote</b>. If <i>UseName</i> is a local device name, the
server MUST locate a <b>UseEntry.ConnectionTable</b> table where <i>UseName</i>
matches <b>Connection.local</b>. If no match is found, the server MUST fail the
call with a NERR_UseNotFound error code.</p><p>If a matching connection is found and <b>IsWorkstationPaused</b>
is TRUE, the server MUST verify the format of <b>Connection.local</b>. If <b>Connection.local</b>
is prefixed with &#34;PRN&#34; or &#34;COM&#34;, the server MUST fail the
call with an ERROR_REDIR_PAUSED error code. If a matching connection is found
and <b>IsWorkstationPaused</b> is FALSE, the server MUST disconnect the
connection with the server by invoking the event specified in <a href="../ms-cifs/d416ff7c-c536-406e-a951-4f04b2fd1d2b" data-linktype="relative-path">[MS-CIFS]</a>
section <a href="../ms-cifs/06cdaae7-2df1-4ee0-a6d7-0824a8812106" data-linktype="relative-path">3.4.4.11</a>,
providing the <b>Connection context</b> handle and <i>ForceLevel</i> as input
parameters.</p><p>If the CIFS server returns a failure, the server MUST fail
the call with the status code ERROR_DEVICE_IN_USE.</p><p>If the CIFS server returns STATUS_SUCCESS, the server MUST
delete the connection in <b>UseEntry.ConnectionTable</b> where <i>UseName</i>
matches <b>Connection.remote</b> and return NERR_Success to the caller.</p><p>If <b>UseEntry.ConnectionTable</b> is empty, the server MUST
remove the <b>UseEntry</b> for the user, where <b>UseEntry.UserToken</b>
matches UserToken.</p><p>The server MUST invoke the event to end the client
impersonation ([MS-RPCE] section <a href="../ms-rpce/53d8f057-4e3a-4bc4-9355-a1cd781de901" data-linktype="relative-path">3.3.3.4.3.3</a>).</p></div>