<div class="content"><p align="right"><a href="https://msdn.microsoft.com/en-us/library/3de62a51-861e-4373-ae2f-f3433cc10106" data-linktype="external">msdn link</a></p><p>The LsarEnumerateTrustedDomains method is invoked to request
a list of <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_f2ceef4e-999b-4276-84cd-2e2829de5fc4" data-linktype="relative-path">trusted domain
objects</a> in the server&#39;s database. The method can be called multiple times
to return its output in fragments.</p><dl>
<dd>
<div><pre> NTSTATUS LsarEnumerateTrustedDomains(
   [in] LSAPR_HANDLE PolicyHandle,
   [in] [out] unsigned long *EnumerationContext,
   [out] PLSAPR_TRUSTED_ENUM_BUFFER EnumerationBuffer,
   [in] unsigned long PreferedMaximumLength
 );
</pre></div>
</dd></dl><p><b>PolicyHandle: </b>An <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a> context handle obtained
from either <a href="2a482ccf-1f89-4693-8594-855ff738ae8a" data-linktype="relative-path">LsarOpenPolicy</a>
or <a href="9456a963-7c21-4710-af77-d0a2f5a72d6b" data-linktype="relative-path">LsarOpenPolicy2</a>.</p><p><b>EnumerationContext: </b>A pointer to a context
value that is used to resume enumeration, if necessary.</p><p><b>EnumerationBuffer: </b>A pointer to a structure
that will contain the results of the enumeration.</p><p><b>PreferedMaximumLength: </b>A value that indicates
the approximate size of the data to be returned.</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>
  <p>0x00000000</p>
  <p>STATUS_SUCCESS</p>
  </td>
  <td>
  <p>The request was successfully completed.</p>
  </td>
 </tr><tr>
  <td>
  <p>0xC0000022</p>
  <p>STATUS_ACCESS_DENIED</p>
  </td>
  <td>
  <p>The caller does not have the permissions to perform
  this operation.</p>
  </td>
 </tr><tr>
  <td>
  <p>0xC0000105</p>
  <p>STATUS_MORE_ENTRIES</p>
  </td>
  <td>
  <p>More information is available to successive calls.</p>
  </td>
 </tr><tr>
  <td>
  <p>0xC000001A</p>
  <p>STATUS_NO_MORE_ENTRIES</p>
  </td>
  <td>
  <p>No more entries are available from the enumeration.</p>
  </td>
 </tr><tr>
  <td>
  <p>0xC0000008</p>
  <p>STATUS_INVALID_HANDLE</p>
  </td>
  <td>
  <p><i>PolicyHandle</i> is not a valid handle.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>Processing:</p><p>This message takes four 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 <a href="d1c2802a-70d5-4f81-843c-6523ab0c5e03" data-linktype="relative-path">3.1.4.2.2</a> with
RequiredAccess set to POLICY_VIEW_LOCAL_INFORMATION.</p><p><i>EnumerationContext</i>: A number that indicates a
starting index at which to begin the enumeration. The server MUST always return
all trusted domain objects in the same order, starting at the object whose
index is <i>EnumerationContext</i>. To initiate a new enumeration, the client
sets <i>EnumerationContext</i> to zero; otherwise, the client sets <i>EnumerationContext</i>
to a value returned by a previous call to the method.</p><p>The server MUST return STATUS_INVALID_PARAMETER if the <i>EnumerationContext</i>
parameter is NULL.</p><p>This method differs from the <a href="14e37cf7-b090-497c-a2e2-97e8425532a2" data-linktype="relative-path">LsarEnumerateTrustedDomainsEx</a>
method in one significant way-in mixed-mode <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_fd104241-4fb3-457c-b2c4-e0c18bb20b62" data-linktype="relative-path">forests</a>, this method
returns to the caller an entire set of <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_b0276eb2-4e65-4cf1-a718-e0920a614aca" data-linktype="relative-path">domains</a> within the forest
by enumerating all the cross-referenced objects in <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_e467d927-17bf-49c9-98d1-96ddf61ddd90" data-linktype="relative-path">Active Directory</a> in
addition to domains that are <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_5ee032d0-d944-4acb-bbb5-b1cfc7df6db6" data-linktype="relative-path">trusted</a>
explicitly.</p><p><i>EnumerationBuffer</i>: Used to return the results of
enumeration. The server MUST fill <i>EnumerationBuffer</i> with as many trusted
domain objects as possible, as determined by <i>PreferedMaximumLength</i>. If
the size of all remaining objects is less than or equal to <i>PreferedMaximumLength</i>,
the server MUST fill <i>EnumerationBuffer</i> with all objects. If the size of
all remaining objects is greater than <i>PreferedMaximumLength</i>, the server
MUST fill <i>EnumerationBuffer</i> with objects such that the size of the
trusted domain objects returned is greater than or equal to <i>PreferedMaximumLength</i>,
but would be less than <i>PreferedMaximumLength</i> if the last object had not
been added to <i>EnumerationBuffer</i>. If there are no more objects than are
returned in <i>EnumerationBuffer</i>, the server MUST return
STATUS_NO_MORE_ENTRIES. If there are more database objects than are returned in
<i>EnumerationBuffer</i>, the server MUST set the <i>EnumerationContext</i>
value to the index value that would allow it to resume enumeration correctly
when this method is called again, and the server MUST return STATUS_MORE_ENTRIES.
Note that this return value is not an error status.</p><p>When enumerating trusted domain objects for this message,
the server MUST limit the trusted domain objects returned to the following
subset only:</p><ul><li><p><span><span> 
</span></span>Outbound Trusts: The trust direction has the
TRUST_DIRECTION_OUTBOUND bit set.</p>
</li><li><p><span><span> 
</span></span>Uplevel or Downlevel Trusts: The trust type is
TRUST_TYPE_DOWNLEVEL or TRUST_TYPE_UPLEVEL.</p>
</li><li><p><span><span> 
</span></span>Non-uplevel-only Trusts: The Trust Attributes field does not have
the TRUST_ATTRIBUTE_UPLEVEL_ONLY bit set.</p>
</li></ul><p>Trust types and attributes are specified in <a href="../ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a" data-linktype="relative-path">[MS-ADTS]</a>
section <a href="../ms-adts/fe369d31-cc17-4ad7-849e-769403bc2c41" data-linktype="relative-path">6.1.6</a>.</p><p><i>PreferedMaximumLength</i>: An indication about the
approximate size, in bytes, of the data to be returned. Any unsigned 32-bit
value is valid for the <i>PreferedMaximumLength</i> parameter.</p><p>If Active Directory is not running on this machine, the
server MUST fill 0 objects in <i>EnumerationBuffer</i>, and return
STATUS_NO_MORE_ENTRIES.</p></div>