<div class="content"><p> </p><p>The NetrSessionDel method MUST end one or more network
sessions between a <span><a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_434b0234-e970-4e8c-bdfa-e16a30d96703" data-linktype="relative-path">server</a></span> and a <span><a href="1709f6a7-efb8-4ded-b7ae-5cee9ee36320#gt_60e0e1fa-66fe-41e1-b5e3-ceab97e53506" data-linktype="relative-path">client</a></span>.</p><dl>
<dd>
<div><pre> NET_API_STATUS NetrSessionDel(
   [in, string, unique] SRVSVC_HANDLE ServerName,
   [in, string, unique] WCHAR* ClientName,
   [in, string, unique] WCHAR* UserName
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>An <span><a href="5f8329ee-1965-4ea1-ad35-3b29fbb63232" data-linktype="relative-path">SRVSVC_HANDLE (section 2.2.1.1)</a></span>
pointer that identifies the server. The client MUST map this structure to an
RPC binding handle (see <span><a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a></span> sections
4.3.5 and 5.1.5.2). The server MUST ignore this parameter.</p><p><b>ClientName: </b>A pointer to a null-terminated
UTF-16 string that specifies the computer name of the client whose sessions are
to be disconnected. This string MUST be one of the following: a NULL
(zero-length) string; or a string that MUST begin with \\.</p><p><b>UserName: </b>A pointer to a null-terminated
UTF-16 string that specifies the user name whose sessions are to be terminated.</p><p><b>Return Values: </b>This method returns 0x00000000
(NERR_Success) to indicate success; otherwise, it returns a nonzero error code.
This method can take any specific error code value, as specified in <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>
section <span><a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a></span>.
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>
  <p>0x00000000</p>
  <p>NERR_Success</p>
  </td>
  <td>
  <p>The client request succeeded.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000005</p>
  <p>ERROR_ACCESS_DENIED</p>
  </td>
  <td>
  <p>Access is denied.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000057</p>
  <p>ERROR_INVALID_PARAMETER</p>
  </td>
  <td>
  <p>The parameter is incorrect.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000008</p>
  <p>ERROR_NOT_ENOUGH_MEMORY</p>
  </td>
  <td>
  <p>Not enough storage is available to process this
  command.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000908</p>
  <p>NERR_ClientNameNotFound</p>
  </td>
  <td>
  <p>A session does not exist with the computer name.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>In response to a NetrSessionDel message, the server ends
network sessions between the server and a workstation.</p><p>The server SHOULD<a id="Appendix_A_Target_53"></a><a aria-label="Product behavior note 53" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_53" data-linktype="relative-path">&lt;53&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_54"></a><a aria-label="Product behavior note 54" href="ebb74ff2-abb1-4e1b-a76a-563a5cbbea9a#Appendix_A_54" data-linktype="relative-path">&lt;54&gt;</a> fail the call.</p><p>The <i>ClientName</i> parameter specifies the computer name
of the client to disconnect. If a <i>ClientName</i> is specified, it MUST start
with &#34;\\&#34;; otherwise, the server MUST fail the call with an
NERR_ClientNameNotFound error code. If a <i>ClientName</i> is specified and it
contains more than 1,024 characters, including the terminating null character,
the server MUST fail the call with an ERROR_INVALID_PARAMETER error code.</p><p>The <i>UserName</i> parameter specifies the name of the user
whose session is to be terminated. If a <i>UserName</i> is specified and the
length of the <i>UserName</i> string, including the terminating null character,
is greater than 1,024, the server MUST fail the call with an
ERROR_INVALID_PARAMETER error code.</p><p>If both <i>ClientName</i> and <i>UserName</i> are
unspecified (a NULL (zero-length) string), the server MUST fail the call with a
NERR_ClientNameNotFound or an ERROR_INVALID_PARAMETER error code.</p><p>The server MUST enumerate all Session entries in <b>SessionList</b>.
For each entry, the server MUST query session properties by invoking the
underlying server events as specified in <span><a href="../ms-cifs/d416ff7c-c536-406e-a951-4f04b2fd1d2b" data-linktype="relative-path">[MS-CIFS]</a></span>
section <span><a href="../ms-cifs/55355166-f9ce-4fba-9f31-983e1ae6bb7f" data-linktype="relative-path">3.3.4.14</a></span>
and <span><a href="../ms-smb2/5606ad47-5ee0-437a-817e-70c366052962" data-linktype="relative-path">[MS-SMB2]</a></span>
section <span><a href="../ms-smb2/0eb76132-1b0f-4b80-a228-8f31d401e7a5" data-linktype="relative-path">3.3.4.18</a></span>,
providing <i>Session.GlobalSessionId</i> as the input parameter. If the server
receives a STATUS_SUCCESS for a <i>Session.GlobalSessionId</i> from either a
CIFS or an SMB2 server, and the received SESSION_INFO_502.sesi502_cname matches
the <i>ClientName</i> (if it is specified) and <b>SESSION_INFO_502.sesi502_username</b>
matches the <i>UserName</i> (if it is specified), the server MUST close the
session by invoking the underlying server event as specified in [MS-CIFS]
section <span><a href="../ms-cifs/5b526bff-bfdb-45ab-a4bf-f80a8917980b" data-linktype="relative-path">3.3.4.8</a></span>
or [MS-SMB2] section <span><a href="../ms-smb2/a0264a5b-595f-472d-a971-1cc142864129" data-linktype="relative-path">3.3.4.12</a></span>,
providing <i>Session.GlobalSessionId</i> as input parameter. The server MUST
continue to query all other sessions and close all the matching sessions.</p><p>If no matching session is found with the <i>ClientName</i>
and <i>UserName</i>, the server MUST fail the call with error code NERR_ClientNameNotFound.</p></div>