<div class="content"><p align="right"><a href="https://msdn.microsoft.com/en-us/library/c842a897-0a42-4ca5-a607-2afd05271dae" data-linktype="external">msdn link</a></p><p>The SamrConnect5 method obtains a handle to a <a href="7b2aeb27-92fc-41f6-8437-deb65d950921#gt_62a8c543-5998-480b-8fa7-41a8f04a18e5" data-linktype="relative-path">server object</a>.</p><dl>
<dd>
<div><pre> long SamrConnect5(
   [in, unique, string] PSAMPR_SERVER_NAME ServerName,
   [in] unsigned long DesiredAccess,
   [in] unsigned long InVersion,
   [in] [switch_is(InVersion)] SAMPR_REVISION_INFO* InRevisionInfo,
   [out] unsigned long* OutVersion,
   [out, switch_is(*OutVersion)] SAMPR_REVISION_INFO* OutRevisionInfo,
   [out] SAMPR_HANDLE* ServerHandle
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>The null-terminated NETBIOS name
of the server; this parameter MAY<a id="Appendix_A_Target_44"></a><a aria-label="Product behavior note 44" href="fa61e5fc-f8fb-4d5b-9695-c724af0c3829#Appendix_A_44" data-linktype="relative-path">&lt;44&gt;</a> be ignored
on receipt.</p><p><b>DesiredAccess: </b>An <a href="../ms-dtyp/7a53f60e-e730-4dfe-bbe9-b21b62eb790b" data-linktype="relative-path">ACCESS_MASK</a>
that indicates the access requested for <i>ServerHandle</i> on output. For a
listing of possible values, see section <a href="e8afb15e-c053-4984-b84b-66877236e141" data-linktype="relative-path">2.2.1.3</a>.</p><p><b>InVersion: </b>Indicates which field of the <i>InRevisionInfo</i>
union is used.</p><p><b>InRevisionInfo: </b>Revision information. For
details, see the definition of the <a href="963e60b5-9233-4669-b8a8-85bf4f0806dc" data-linktype="relative-path">SAMPR_REVISION_INFO_V1</a>
structure, which is contained in the <a href="9ee412b6-d5e9-4c6c-921f-6f684d4c3079" data-linktype="relative-path">SAMPR_REVISION_INFO</a> union.</p><p><b>OutVersion: </b>Indicates which field of the <i>OutRevisionInfo</i>
union is used.</p><p><b>OutRevisionInfo: </b>Revision information. For
details, see the definition of the SAMPR_REVISION_INFO_V1 structure, which is
contained in the SAMPR_REVISION_INFO union.</p><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>.</p><p>Upon 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
translate the following bits in <i>DesiredAccess</i> according to the following
table. Translate means to remove the &#34;Incoming Bit&#34; and replace with
the &#34;Translated Bits&#34;.</p>
<table><thead>
  <tr>
   <th>
   <p>Incoming bit</p>
   </th>
   <th>
   <p>Translated bits</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>GENERIC_READ</p>
  </td>
  <td>
  <p>SAM_SERVER_READ</p>
  </td>
 </tr><tr>
  <td>
  <p>GENERIC_WRITE</p>
  </td>
  <td>
  <p>SAM_SERVER_WRITE</p>
  </td>
 </tr><tr>
  <td>
  <p>GENERIC_EXECUTE</p>
  </td>
  <td>
  <p>SAM_SERVER_EXECUTE</p>
  </td>
 </tr><tr>
  <td>
  <p>GENERIC_ALL</p>
  </td>
  <td>
  <p>SAM_SERVER_ALL_ACCESS</p>
  </td>
 </tr></tbody></table>
</li><li><p><span>    </span>Let S be the
server object in the account domain.</p>
</li><li><p><span>    </span>Let
GrantedAccess be the union of all bits in the <i>DesiredAccess</i> column in
the following table, where the client has the specified access (shown in the
Access Mask column) on the <b>ntSecurityDescriptor</b> on S. <a href="../ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a" data-linktype="relative-path">[MS-ADTS]</a>
section <a href="../ms-adts/3da5080d-de25-4ac8-9f2b-982709253dfb" data-linktype="relative-path">5.1.3.3.3</a>
specifies how to determine the client&#39;s access.</p>
<table><thead>
  <tr>
   <th>
   <p>DesiredAccess</p>
   </th>
   <th>
   <p>Access mask</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>SAM_SERVER_CONNECT</p>
  </td>
  <td>
  <p>ACTRL_DS_READ_PROP</p>
  </td>
 </tr><tr>
  <td>
  <p>SAM_SERVER_SHUTDOWN</p>
  </td>
  <td>
  <p>ACTRL_DS_WRITE_PROP</p>
  </td>
 </tr><tr>
  <td>
  <p>SAM_SERVER_INITIALIZE</p>
  </td>
  <td>
  <p>ACTRL_DS_WRITE_PROP</p>
  </td>
 </tr><tr>
  <td>
  <p>SAM_SERVER_CREATE_DOMAIN</p>
  </td>
  <td>
  <p>ACTRL_DS_WRITE_PROP</p>
  </td>
 </tr><tr>
  <td>
  <p>SAM_SERVER_ENUMERATE_DOMAINS</p>
  </td>
  <td>
  <p>ACTRL_DS_READ_PROP</p>
  </td>
 </tr><tr>
  <td>
  <p>SAM_SERVER_LOOKUP_DOMAIN</p>
  </td>
  <td>
  <p>ACTRL_DS_READ_PROP</p>
  </td>
 </tr><tr>
  <td>
  <p>ACCESS_SYSTEM_SECURITY</p>
  </td>
  <td>
  <p>ACCESS_SYSTEM_SECURITY</p>
  </td>
 </tr><tr>
  <td>
  <p>WRITE_OWNER</p>
  </td>
  <td>
  <p>WRITE_OWNER</p>
  </td>
 </tr><tr>
  <td>
  <p>WRITE_DAC</p>
  </td>
  <td>
  <p>WRITE_DAC</p>
  </td>
 </tr><tr>
  <td>
  <p>DELETE</p>
  </td>
  <td>
  <p>DELETE</p>
  </td>
 </tr></tbody></table>
</li><li><p><span>    </span>If GrantedAccess
is 0, the server MUST return STATUS_ACCESS_DENIED.</p>
</li><li><p><span>    </span>If <i>DesiredAccess</i>
contains the MAXIMUM_ALLOWED bit, the server MUST create and return a
SamContextHandle (section <a href="cc2dc6ce-e45f-481a-a8ed-5d0e273336b3" data-linktype="relative-path">3.1.1.10</a>)
via ServerHandle, with its fields initialized as follows:</p>
<ul><li><p><span><span>  </span></span>SamContextHandle.HandleType
= &#34;Server&#34;</p>
</li><li><p><span><span>  </span></span>SamContextHandle.Object
= S</p>
</li><li><p><span><span>  </span></span>SamContextHandle.GrantedAccess
= GrantedAccess</p>
</li></ul></li><li><p><span>    </span>If <i>DesiredAccess</i>
does not contain the MAXIMUM_ALLOWED bit, the following constraint MUST be
satisfied:</p>
<ul><li><p><span><span>  </span></span>If <i>DesiredAccess</i>
contains bits not in GrantedAccess, the server MUST return
STATUS_ACCESS_DENIED. Otherwise, the server MUST create and return a
SamContextHandle (section 3.1.1.10) via ServerHandle, with its fields
initialized as follows:</p>
<ul><li><p><span><span> 
</span></span>SamContextHandle.HandleType = &#34;Server&#34;</p>
</li><li><p><span><span> 
</span></span>SamContextHandle.Object = S</p>
</li><li><p><span><span> 
</span></span>SamContextHandle.GrantedAccess = <i>DesiredAccess</i></p>
</li></ul></li></ul></li><li><p><span>    </span>If <i>InVersion</i>
is not equal to 1, the server MUST return STATUS_NOT_SUPPORTED.</p>
</li><li><p><span>    </span>The server MUST
set <i>OutVersion</i> to 1 and OutRevisionInfo.Revision to 3. The remaining
fields of <i>OutRevisionInfo</i> MUST be set to zero.</p>
</li><li><p><span>    </span>If any
processing error occurred, the server MUST return that error. Otherwise, the
server MUST return STATUS_SUCCESS.</p>
</li></ol></div>