<div class="content" name="LsarOpenSecret" uuid="8bf25269-014f-43fd-b80f-7a59a4883451"><p>The LsarOpenSecret method is invoked to obtain a handle to
an existing <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_9720ddb8-c802-40b7-8dba-5e7520c3396d" data-linktype="relative-path">secret object</a></span>. </p><dl>
<dd>
<div><pre> NTSTATUS LsarOpenSecret(
   [in] LSAPR_HANDLE PolicyHandle,
   [in] PRPC_UNICODE_STRING SecretName,
   [in] ACCESS_MASK DesiredAccess,
   [out] LSAPR_HANDLE* SecretHandle
 );
</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>SecretName: </b>The name of the secret object to
open.</p><p><b>DesiredAccess: </b>The requested type of access.</p><p><b>SecretHandle: </b>Used to return the handle to the
opened secret object.</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>0xC0000034 STATUS_OBJECT_NAME_NOT_FOUND</td>
  <td>The secret with the specified name was not found.</td>
 </tr><tr>
  <td>0xC0000008 STATUS_INVALID_HANDLE</td>
  <td>PolicyHandle is not a valid handle.</td>
 </tr><tr>
  <td>0xC000000D STATUS_INVALID_PARAMETER</td>
  <td>Some of the parameters supplied were invalid.</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.
<i>PolicyHandle</i>.GrantedAccess MUST NOT be considered for this call because
the access check MUST happen on the secret object.</p><p><i>SecretName</i>: The name of the secret to be opened. The
server MUST verify that the name syntax restrictions on secrets specified in
section <span><a href="35a984a1-d002-4d60-946d-b557ff4c46e0" data-linktype="relative-path">3.1.4.6.1</a></span> are
satisfied, and fail the request with STATUS_INVALID_PARAMETER otherwise. The
server MUST verify that the secret object with this name exists in its policy
database and fail the request with STATUS_OBJECT_NAME_NOT_FOUND otherwise.<a id="Appendix_A_Target_80"></a><a aria-label="Product behavior note 80" href="2a769a08-e023-459f-aebe-4fb3f595c0b7#Appendix_A_80" data-linktype="relative-path">&lt;80&gt;</a></p><p><i>DesiredAccess</i>: A bitmask specifying the type of
access that the caller attempts to obtain from the secret object, which is
access-checked according to section <span><a href="e5e1e32e-4066-435d-b669-044fe997eaf7" data-linktype="relative-path">3.1.4.2.1</a></span>. The
method-specific portion of the check is as follows:</p><dl>
<dd>
<div><pre> IF (IsRequestorAnonymous() and LsaRestrictAnonymous is set to TRUE) THEN
     Return STATUS_OBJECT_NAME_NOT_FOUND
 END IF
</pre></div>
</dd></dl><p>The valid secret-rights bits are specified in section <span><a href="88c6bd18-6c40-4a82-ae19-fe7bfec5108b" data-linktype="relative-path">2.2.1.1.4</a></span>
and the <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_e5213722-75a9-44e7-b026-8e4833f0d350" data-linktype="relative-path">security descriptor</a></span>
is specified in section <span><a href="483f1b6e-7b14-4341-9ab2-9b99c01f896e" data-linktype="relative-path">3.1.1.4</a></span>. The
IsRequestorAnonymous procedure is specified in section <span><a href="5d50b55f-e9c7-4af6-bf85-02e8043f66ea" data-linktype="relative-path">3.1.4.2.3</a></span>.</p><p><i>SecretHandle</i>: If the request is successful, this
parameter is used to return a handle (section <span><a href="1011130b-0413-460d-81ed-d1821d141639" data-linktype="relative-path">3.1.1.7</a></span>) to the
opened secret object with its fields initialized as follows:</p><ul><li><p><span><span> 
</span></span>LsaContextHandle.HandleType = &#34;Secret&#34;</p>
</li><li><p><span><span> 
</span></span>LsaContextHandle.Object = the secret object</p>
</li><li><p><span><span> 
</span></span>LsaContextHandle.GrantedAccess = as specified in section
3.1.4.2.1</p>
</li></ul></div>