<div class="content" name="LsarEnumerateAccountsWithUserRight" uuid="9c6ec6db-534b-41d5-bbac-faa9ad31b380"><p>The LsarEnumerateAccountsWithUserRight method is invoked to
return a list of <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_b76eee27-064e-461b-81a9-fbf41e49928b" data-linktype="relative-path">account objects</a></span> that
have the user right equal to the passed-in value.</p><dl>
<dd>
<div><pre> NTSTATUS LsarEnumerateAccountsWithUserRight(
   [in] LSAPR_HANDLE PolicyHandle,
   [in, unique] PRPC_UNICODE_STRING UserRight,
   [out] PLSAPR_ACCOUNT_ENUM_BUFFER EnumerationBuffer
 );
</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>UserRight: </b>The name of the right to use in
enumeration.</p><p><b>EnumerationBuffer: </b>Used to return the list of
account objects that have the specified right.</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>0xC0000008 STATUS_INVALID_HANDLE</td>
  <td>PolicyHandle is not a valid handle.</td>
 </tr><tr>
  <td>0xC0000060 STATUS_NO_SUCH_PRIVILEGE</td>
  <td>The supplied name is not recognized by the server.</td>
 </tr><tr>
  <td>0xC000000D STATUS_INVALID_PARAMETER</td>
  <td>One of the supplied arguments is invalid.</td>
 </tr><tr>
  <td>0x8000001A STATUS_NO_MORE_ENTRIES</td>
  <td>No account was found with the specified privilege.</td>
 </tr></tbody></table>
</dd></dl><p>Processing:</p><p>This message takes three 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 <span><a href="d1c2802a-70d5-4f81-843c-6523ab0c5e03" data-linktype="relative-path">3.1.4.2.2</a></span> with
RequiredAccess set to POLICY_VIEW_LOCAL_INFORMATION.<a id="Appendix_A_Target_73"></a><a aria-label="Product behavior note 73" href="2a769a08-e023-459f-aebe-4fb3f595c0b7#Appendix_A_73" data-linktype="relative-path">&lt;73&gt;</a></p><p><i>UserRight</i>: A string representation of an account
right. If the server does not recognize the account right, it MUST return
STATUS_NO_SUCH_PRIVILEGE.</p><p>The server executes the request by going through all
accounts in its policy database and returning a set of all account object <span><a href="31ca2a31-0be4-4773-bcef-05ad6cd3ccfb#gt_83f2020d-0804-4840-a5ac-e06439d50f8d" data-linktype="relative-path">SIDs</a></span>
that have that right or privilege.</p><p><i>EnumerationBuffer</i>: Used to return a set of account
SIDs that have the specified UserRight.</p></div>