Answers.Body: <p>I don't think there is a clean or particularly efficient way of doing this using Craft's current services.</p>
  
  <p>It'd have to be something like:</p>
  
  <pre><code>1. Grab all users
  2. Loop through them calling craft()-&gt;userPermissions-&gt;doesUserHavePermission()
  3. If true, save user in success array.
  </code></pre>
  
  <p>Alternatively you could use <a href="http://buildwithcraft.com/classreference/etc/db/DbCommand" rel="nofollow">DbCommand</a> to query the database directly for the info you're looking for.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-21T22:17:11.670Z
Answers.LastActivityDate: 2015-04-21T22:17:11.670Z
Answers.UserDisplayName: Brad Bell
Body: <p>With a <code>$user</code> object, we can verify the user against a permission setting with the <code>can()</code> method. However, how can I retrieve all users who have a specific permission, including those under a group with the permission.</p>
  
  <p>This needs to be generic PHP code as it's located in a service.</p>
  
Tags: <permissions>
Title: Retrieving all users with specified permission
ThreadText: # Retrieving all users with specified permission
  
  (Asked by: username_0 on 2015-04-21)
  
  With a `$user` object, we can verify the user against a permission setting with the `can()` method. However, how can I retrieve all users who have a specific permission, including those under a group with the permission.
  
  This needs to be generic PHP code as it's located in a service.
  
  **Tags:** permissions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-21. Score: 1
  
  I don't think there is a clean or particularly efficient way of doing this using Craft's current services.
  
  It'd have to be something like:
  
  ```
  1. Grab all users
  2. Loop through them calling craft()->userPermissions->doesUserHavePermission()
  3. If true, save user in success array.
  
  ```
  
  Alternatively you could use [DbCommand](http://buildwithcraft.com/classreference/etc/db/DbCommand) to query the database directly for the info you're looking for.
  
  
  ---
  
  