<div class="content" name="LsarDeleteTrustedDomain" uuid="633788c9-1e98-4555-bc41-d78a0de0f4a4"><p>The LsarDeleteTrustedDomain method is invoked to delete a <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_f2ceef4e-999b-4276-84cd-2e2829de5fc4" data-linktype="relative-path">trusted
domain object (TDO)</a></span>.</p><dl>
<dd>
<div><pre> NTSTATUS LsarDeleteTrustedDomain(
   [in] LSAPR_HANDLE PolicyHandle,
   [in] PRPC_SID TrustedDomainSid
 );
</pre></div>
</dd></dl><p><b>PolicyHandle: </b>An <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a></span> context handle
obtained from either <span><a href="2a482ccf-1f89-4693-8594-855ff738ae8a" data-linktype="relative-path">LsarOpenPolicy</a></span> or <span><a href="9456a963-7c21-4710-af77-d0a2f5a72d6b" data-linktype="relative-path">LsarOpenPolicy2</a></span>.</p><p><b>TrustedDomainSid: </b>A <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_e5213722-75a9-44e7-b026-8e4833f0d350" data-linktype="relative-path">security descriptor</a></span>
of the TDO to be deleted.</p><p><b>Return Values: </b>The following is a summary of
the return values that an implementation MUST return, as specified by the
message processing that follows.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 STATUS_SUCCESS</td>
  <td>The request was successfully completed.</td>
 </tr><tr>
  <td>0xC0000022 STATUS_ACCESS_DENIED</td>
  <td>The caller does not have the permissions to perform this operation.</td>
 </tr><tr>
  <td>0xC00000DF STATUS_NO_SUCH_DOMAIN</td>
  <td>The specified TDO does not exist.</td>
 </tr><tr>
  <td>0xC000000D STATUS_INVALID_PARAMETER</td>
  <td>One or more of the supplied parameters was invalid.</td>
 </tr><tr>
  <td>0xC0000008 STATUS_INVALID_HANDLE</td>
  <td>PolicyHandle is not a valid handle.</td>
 </tr><tr>
  <td>0xC00002B1 STATUS_DIRECTORY_SERVICE_REQUIRED</td>
  <td>The Active Directory service was not available on the server.</td>
 </tr><tr>
  <td>0xC0000403 STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED</td>
  <td>The caller&#39;s quota for the maximum allowed number of deleted TDOs is exceeded.</td>
 </tr></tbody></table>
</dd></dl><p>Processing:</p><p>If Active Directory is not running on this machine, the
server MUST return STATUS_DIRECTORY_SERVICE_REQUIRED.</p><p>If the number of deleted TDOs that were created by the
caller through the control access right Create-Inbound-Trust (defined in <span><a href="../ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a" data-linktype="relative-path">[MS-ADTS]</a></span>
section <span><a href="../ms-adts/1522b774-6464-41a3-87a5-1e5633c3fbbb" data-linktype="relative-path">5.1.3.2.1</a></span>)
exceeds the value in the msDS-PerUserTrustTombstonesQuota attribute of the <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_40a58fa4-953e-4cf3-96c8-57dba60237ef" data-linktype="relative-path">domain
naming context (domain NC)</a></span> root object (defined in [MS-ADTS] section
<span><a href="../ms-adts/d119446e-3f8c-4610-9db6-2283200b6ec7" data-linktype="relative-path">6.1.1.1.4</a></span>),
the server MUST return STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED. For the syntax
of the msDS-PerUserTrustTombstonesQuota attribute, refer to <span><a href="../ms-ada2/e20ebc4e-5285-40ba-b3bd-ffcb81c2783e" data-linktype="relative-path">[MS-ADA2]</a></span>
section <span><a href="../ms-ada2/2df0cabf-1c76-4dc5-bf9d-b7a50f9796f8" data-linktype="relative-path">2.424</a></span>.
The server MUST enforce the quota check only for the TDOs created by control
access right Create-Inbound-Trust and if the caller is the creator of that TDO.</p><p>This message takes two arguments:</p><p><i>PolicyHandle</i>: An open handle to the policy object. If
the handle is not a valid context handle to the policy object or <i>PolicyHandle</i>.HandleType
does not equal &#34;Policy&#34;, the server MUST return
STATUS_INVALID_HANDLE. The server MUST verify that <i>PolicyHandle</i> grants
access as specified in section <span><a href="d1c2802a-70d5-4f81-843c-6523ab0c5e03" data-linktype="relative-path">3.1.4.2.2</a></span> with
RequiredAccess set to TRUSTED_QUERY_DOMAIN_NAME | DELETE.</p><p><i>TrustedDomainSid</i>: The <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_83f2020d-0804-4840-a5ac-e06439d50f8d" data-linktype="relative-path">SID</a></span> of a TDO to be
deleted. The server MUST verify that the caller has supplied a valid <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_b0276eb2-4e65-4cf1-a718-e0920a614aca" data-linktype="relative-path">domain</a></span>
SID for this parameter and fail the request with STATUS_INVALID_PARAMETER if
the check fails. The server MUST verify that a TDO with this SID exists in its
policy database and fail the request with STATUS_NO_SUCH_DOMAIN otherwise.</p><p> If the server is a <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_8b0a073b-3099-4efe-8b81-c2886b66a870" data-linktype="relative-path">read-only domain controller</a></span>,
it MUST return an error.<a id="Appendix_A_Target_99"></a><a aria-label="Product behavior note 99" href="2a769a08-e023-459f-aebe-4fb3f595c0b7#Appendix_A_99" data-linktype="relative-path">&lt;99&gt;</a></p><p>The server MUST also check whether a secret with name
&#34;G$$&lt;Trusted Domain Name&gt;&#34; exists or not. If it exists, the
server MUST delete that secret along with the <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_f2f00d47-6cf2-4b32-b8f7-b63e38e2e9c4" data-linktype="relative-path">trusted domain</a></span>.</p><p>The server MUST also check whether an <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_ba0d31d7-aa03-4e10-936a-a0ebd276ebc9" data-linktype="relative-path">interdomain
trust account</a></span> with name &#34;&lt;Trusted Domain NetBIOS
Name&gt;$&#34; exists. If it exists, the server MUST delete that account along
with the trusted domain.</p></div>