<div class="content"><p align="right"><a href="https://msdn.microsoft.com/en-us/library/16be42bc-e85c-4135-b183-aacb88106306" data-linktype="external">msdn link</a></p><p>The LsarSetForestTrustInformation method is invoked to
establish a <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_5ee032d0-d944-4acb-bbb5-b1cfc7df6db6" data-linktype="relative-path">trust</a>
relationship with another <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_fd104241-4fb3-457c-b2c4-e0c18bb20b62" data-linktype="relative-path">forest</a>
by attaching a set of records called the <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_8c0b82d9-efec-4723-95a9-8564edf9ba44" data-linktype="relative-path">forest trust information</a> to
the <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_f2ceef4e-999b-4276-84cd-2e2829de5fc4" data-linktype="relative-path">trusted domain object</a>.</p><dl>
<dd>
<div><pre> NTSTATUS LsarSetForestTrustInformation(
   [in] LSAPR_HANDLE PolicyHandle,
   [in] PLSA_UNICODE_STRING TrustedDomainName,
   [in] LSA_FOREST_TRUST_RECORD_TYPE HighestRecordType,
   [in] PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
   [in] unsigned char CheckOnly,
   [out] PLSA_FOREST_TRUST_COLLISION_INFORMATION* CollisionInfo
 );
</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>TrustedDomainName: </b>The name of the trusted
domain object on which to set the forest trust information.</p><p><b>HighestRecordType: </b>The highest ordinal <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_035d9ce5-f117-4251-8d4d-127c462ec4a0" data-linktype="relative-path">forest trust</a> record type
that the caller understands.</p><p><b>ForestTrustInfo: </b>The forest trust information
that the caller is trying to set on the trusted domain object.</p><p><b>CheckOnly: </b>If not 0, the operation is
read-only and does not alter the state of the server&#39;s database.</p><p><b>CollisionInfo: </b>Used to return information
about collisions between different sets of forest trust information in the
server&#39;s database.</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>0xC00000DD</p>
  <p>STATUS_INVALID_DOMAIN_STATE</p>
  </td>
  <td>
  <p>The <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_b0276eb2-4e65-4cf1-a718-e0920a614aca" data-linktype="relative-path">domain</a>
  is not the <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_529c766b-af01-4bc8-b853-65fba6c704b3" data-linktype="relative-path">root domain</a>
  of the forest, or the forest is not at DS_BEHAVIOR_WIN2003 <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_b3240417-ca43-4901-90ec-fde55b32b3b8" data-linktype="relative-path">forest functional level</a>.</p>
  </td>
 </tr><tr>
  <td>
  <p>0xC00000DE</p>
  <p>STATUS_INVALID_DOMAIN_ROLE</p>
  </td>
  <td>
  <p>The server is not the <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_663cb13a-8b75-477f-b6e1-bea8f2fba64d" data-linktype="relative-path">primary domain controller</a>.</p>
  </td>
 </tr><tr>
  <td>
  <p>0xC00000DF</p>
  <p>STATUS_NO_SUCH_DOMAIN</p>
  </td>
  <td>
  <p>The trusted domain object with the name in the <i>TrustedDomainName</i>
  parameter does not exist.</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><tr>
  <td>
  <p>0xC000000D</p>
  <p>STATUS_INVALID_PARAMETER</p>
  </td>
  <td>
  <p>Some of the parameters supplied were invalid.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>Processing instructions:</p><p>This message takes six arguments:</p><p><i>PolicyHandle</i>: 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. <i>PolicyHandle</i>.GrantedAccess MUST NOT be considered
for this call because the access check MUST happen on the trusted domain
object.</p><p><i>TrustedDomainName</i>: The name of the trusted domain
object to set forest trust information on.</p><p>The server MUST return STATUS_INVALID_DOMAIN_STATE if any of
the following conditions is TRUE.</p><ul><li><p><span><span> 
</span></span>The <b>DnsForestName</b> and <b>DnsDomainName</b> fields in DNS
Domain Information (see section <a href="c939c70e-8cf0-4d90-a9cc-1c5002951723" data-linktype="relative-path">3.1.1.1</a>) do not contain
the same value.</p>
</li><li><p><span><span> 
</span></span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_e467d927-17bf-49c9-98d1-96ddf61ddd90" data-linktype="relative-path">Active
Directory</a> is not running on this machine.</p>
</li></ul><p>The server MUST return STATUS_INVALID_DOMAIN_ROLE if the
IsEffectiveRoleOwner function specified in <a href="../ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a" data-linktype="relative-path">[MS-ADTS]</a>
section <a href="../ms-adts/111c589d-284a-427a-91e9-9031a3767597" data-linktype="relative-path">3.1.1.5.1.8</a>
returns FALSE with the roleObject parameter set to default NC.</p><p>If a trusted domain object by the name <i>TrustedDomainName</i>
does not exist, the server MUST return STATUS_NO_SUCH_DOMAIN.</p><p>The server MUST verify that the caller has access to the
trusted domain object as specified in section <a href="e5e1e32e-4066-435d-b669-044fe997eaf7" data-linktype="relative-path">3.1.4.2.1</a> with <i>DesiredAccess</i>
set to TRUSTED_SET_AUTH. There is no method-specific portion of this check.</p><p>The server MUST also make sure that the <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_0b8230da-0fd8-492c-b84a-d8467c3dc1ef" data-linktype="relative-path">trust attributes</a> associated
with the trusted domain object referenced by the <i>TrustedDomainName</i>
parameter has the TRUST_ATTRIBUTE_FOREST_TRANSITIVE set. If the attribute is
not present, the server MUST return STATUS_INVALID_PARAMETER.</p><p><i>HighestRecordType</i>: The caller sets this argument to
the highest <a href="700a91e8-a1a4-4e1b-9ad6-096b3cf0bef0" data-linktype="relative-path">LSA_FOREST_TRUST_RECORD_TYPE</a>
enumeration value recognized by the caller. If this argument is greater in
value than the highest record type recognized by the server, the server MUST
return STATUS_INVALID_PARAMETER.</p><p><i>ForestTrustInfo</i>: A collection of forest trust records
identifying the topology of the <a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_3b76a71f-9697-4836-9c69-09899b23c21b" data-linktype="relative-path">trusted forest</a>. The server
MUST verify that the forest trust information supplied by the caller is valid
by performing a consistency check, as specified in [MS-ADTS] section <a href="../ms-adts/fe369d31-cc17-4ad7-849e-769403bc2c41" data-linktype="relative-path">6.1.6</a>.
Note that &#34;consistent&#34; does not necessarily mean
&#34;collision-free&#34;. The method for determining collisions is specified
in section <a href="f0e0eefd-e53c-463b-b816-86fb21931366" data-linktype="relative-path">3.1.4.7.16.1</a>.
</p><p>Records supplied by the caller in the Data field (section <a href="08cf1a65-ef7c-46d3-aa4d-558f5135df3d" data-linktype="relative-path">2.2.7.21</a>), using the
opaque LSA_FOREST_TRUST_BINARY_DATA structure (section <a href="d4859b44-b776-4237-baa1-12dc28c19634" data-linktype="relative-path">2.2.7.23</a>), MUST be parsed
using the SubRecordType field. If SubRecordType ([MS-ADTS] section <a href="../ms-adts/96e44639-eb3e-48c3-a565-1d67cceb3bad" data-linktype="relative-path">6.1.6.9.3</a>)
is a known record type, the record MUST be validated\persisted as that record
type (section <a href="0228f75e-9725-479c-b4cd-1cacd667343c" data-linktype="relative-path">3.1.1.5</a>).
</p><p>ForestTrustScannerInfo (section <a href="ee2806eb-20d1-4089-97f2-db7384ea4933" data-linktype="relative-path">2.2.7.31</a>) records MUST
contain DnsName and NetbiosName data, but are not otherwise validated. Note
that collision name checking is not done on ForestTrustScannerInfo records.</p><p><i>CheckOnly</i>: Perform a read-only probing operation. The
results will not be persisted in the Local Security Authority (Domain Policy)
database, but the set of collision records returned in <i>CollisionInfo</i>
will be accurate as though the information was persisted.</p><p><i>CollisionInfo</i>: A list of collision records. The
request is considered successful even if a non-empty set of collisions is
returned. The rules for generating collision information are specified in
section 3.1.4.7.16.1.</p><p>The server MUST store the generated <i>ForestTrustInfo</i>
in the Forest Trust Information attribute specified in section 3.1.1.5.</p></div>