title: How to obtain a list of all users with access to a Google shared drive using apps script
body: <p>I used getEditors to obtain a list of editors of a spreadsheet and the returned list includes shared drive users. However, users with 'content manager' access to the shared drive are not included in the list. Any reason why this is the case?</p>
  <p>I also found that getAccess may be used to obtain the type of access a specific user has to a drive folder. Using this approach, my objective would be to identify all users with FILE_ORGANIZER or ORGANIZER permission. See <a href="https://developers.google.com/apps-script/reference/drive/permission" rel="nofollow noreferrer">official documentation on permissions</a>.
  Is it possible to use an if statement or a loop to get this information?</p>
  <p>Alternatively, is there a workaround to obtaining a list of all users with access to a shared drive that I might not have considered?</p>
  <p>PS: Advanced drive service is not enabled.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// This code aims to protect a sheet in a spreadsheet 
  // by granting specific users access (super users) 
  // and revoking the access of any other user that can edit the spreadsheet. 
  
  /*
  Attempted approach:
  
  user1 and user2 have manager permission to the shared drive as a whole
  user3 has content manager permission to the shared drive as a whole
  user4 only has access to this spreadsheet in the shared drive
  
  My objective is to ensure that only users 1 and 2 can edit the protected sheet.
  
  Result:
  Log shows that users 1 and 2 have access and user 4 does not.
  However, user3 can still edit the sheet because they were no included in the getEditors() result hence their access could not be revoked. 
  */
  
  function protectASheet() {
    var superusers = ['user1', 'user2'];
    var ss = SpreadsheetApp.getActive();
    var editors = ss.getEditors(); //get file editors
    var sheet = SpreadsheetApp.getActive().getSheetByName('TestSheet');
  
    //Set protection  
    var protection = sheet.protect().setDescription('This sheet is protected.');
  
    protection.addEditors(superusers); //Grant superusers edit permission
    protection.removeEditors(editors); //Revoke other file editors' permission
  
    Logger.log("Only the following can edit " + sheet.getSheetName() + ": " + protection.getEditors());
  
  
  }</code></pre>
  </div>
  </div>
  </p>