<div class="content"><p align="right"><a href="https://msdn.microsoft.com/en-us/library/2142fd2d-0854-42c1-a9fb-2fe964e381ce" data-linktype="external">msdn link</a></p><p>The SamrEnumerateDomainsInSamServer method obtains a listing
of all <a href="7b2aeb27-92fc-41f6-8437-deb65d950921#gt_b0276eb2-4e65-4cf1-a718-e0920a614aca" data-linktype="relative-path">domains</a> hosted by
the server side of this protocol.</p><dl>
<dd>
<div><pre> long SamrEnumerateDomainsInSamServer(
   [in] SAMPR_HANDLE ServerHandle,
   [in, out] unsigned long* EnumerationContext,
   [out] PSAMPR_ENUMERATION_BUFFER* Buffer,
   [in] unsigned long PreferedMaximumLength,
   [out] unsigned long* CountReturned
 );
</pre></div>
</dd></dl><p><b>ServerHandle: </b>An RPC context handle, as
specified in section <a href="8138c078-d881-4d1f-b378-94b4c34a287a" data-linktype="relative-path">2.2.7.2</a>,
representing a <a href="7b2aeb27-92fc-41f6-8437-deb65d950921#gt_62a8c543-5998-480b-8fa7-41a8f04a18e5" data-linktype="relative-path">server object</a>.</p><p><b>EnumerationContext: </b>This value is a cookie
that the server can use to continue an enumeration on a subsequent call. It is an
opaque value to the client. 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><b>Buffer: </b>A listing of domain information, as
described in section <a href="c53161a4-38e8-4a28-a33e-0d378fce03dd" data-linktype="relative-path">2.2.7.10</a>.</p><p><b>PreferedMaximumLength: </b>The requested maximum
number of bytes to return in <i>Buffer</i>.</p><p><b>CountReturned: </b>The count of domain elements
returned in <i>Buffer</i>.</p><p>This method asks the RPC runtime, via the <b>strict_context_handle</b>
attribute, to reject the use of context handles created by a method of a
different RPC interface than this one, as specified in <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>
section <a href="../ms-rpce/38ae9f5a-dac2-46ad-b2b7-9c43f211d9f6" data-linktype="relative-path">3</a>.</p><p>On receiving this message, the server MUST process the data
from the message subject to the following constraints:</p><ol><li><p><span>    </span>The server MUST
return an error if <i>ServerHandle.HandleType</i> is not equal to
&#34;Server&#34;.</p>
</li><li><p><span>    </span><i>ServerHandle.GrantedAccess</i>
MUST have the required access specified in section <a href="87bacbd0-7b8b-429f-abc6-4b3d895d4e90" data-linktype="relative-path">3.1.2.2</a>. Otherwise, the
server MUST return STATUS_ACCESS_DENIED.</p>
</li><li><p><span>    </span>The server MUST
enable a client to obtain a listing, without duplicates, of the following two
values: the name attribute of the <a href="7b2aeb27-92fc-41f6-8437-deb65d950921#gt_3ff707e8-0783-4b16-9370-2899f1078c87" data-linktype="relative-path">account domain object</a> and
the name attribute of the <a href="7b2aeb27-92fc-41f6-8437-deb65d950921#gt_22904540-f2fb-470e-af48-ce1b0e9a02b8" data-linktype="relative-path">built-in
domain</a> object.</p>
</li><li><p><span>    </span><i>EnumerationContext</i>
MUST be used to allow the client implementation to pass back to the server, on
a subsequent call, information on the last <a href="7b2aeb27-92fc-41f6-8437-deb65d950921#gt_60122e64-9d34-40ee-a387-782eaf7adf2f" data-linktype="relative-path">database object</a> that was
returned using <i>EnumerationContext</i>.</p>
</li><li><p><span>    </span>Servers SHOULD<a id="Appendix_A_Target_48"></a><a aria-label="Product behavior note 48" href="fa61e5fc-f8fb-4d5b-9695-c724af0c3829#Appendix_A_48" data-linktype="relative-path">&lt;48&gt;</a> validate that <i>EnumerationContext</i>
is an expected value for the server&#39;s implementation.</p>
</li><li><p><span>    </span>The server
SHOULD<a id="Appendix_A_Target_49"></a><a aria-label="Product behavior note 49" href="fa61e5fc-f8fb-4d5b-9695-c724af0c3829#Appendix_A_49" data-linktype="relative-path">&lt;49&gt;</a> fill Buffer.Buffer with as many
entries as possible, such that not more than <i>PreferedMaximumLength</i> bytes
are returned in Buffer.Buffer. If the server returns more than <i>PreferedMaximumLength</i>
bytes, the difference between <i>PreferedMaximumLength</i> and the actual
number of bytes returned MUST be less than the maximum size, in bytes, of one
entry in the array Buffer.Buffer.</p>
</li><li><p><span>    </span>Each element of
Buffer.Buffer MUST represent one database object that matches the criteria from
item 2 above, and MUST be filled as follows:</p>
<ol><li><p><span>   
</span>Buffer.Buffer.Name is the name attribute value of the database object.</p>
</li><li><p><span>   
</span>Buffer.Buffer.RelativeId is 0.</p>
</li></ol></li><li><p><span>    </span>On output, <i>CountReturned</i>
MUST equal Buffer.EntriesRead.</p>
</li><li><p><span>    </span>STATUS_MORE_ENTRIES
MUST be returned if the server returns less than all of the database objects in
Buffer.Buffer because of the <i>PreferedMaximumLength</i> restriction described
above. Note that this return value is not an error status.</p>
</li><li><p><span>  </span>If there are no entries or
Buffer.Buffer contains all matching database objects that remain, the server
MUST return STATUS_SUCCESS.</p>
</li></ol></div>