Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all Google Apps users not using two-factor authentication

We're implementing two-factor authentication for all of our Google Apps users.

I've written a script to list the users in a Google Apps domain based on the sample that Google provides (https://developers.google.com/apps-script/advanced/admin-sdk-directory#list_all_users)

I'd like to filter that list by users who are or aren't using two-factor authentication but I cannot find anywhere in the User API that allows me to do this.

Does anyone know who I can find out if a user is using two-factor authentication or not?

like image 704
John Reid Avatar asked Sep 01 '14 10:09

John Reid


People also ask

How do I bypass two factor authentication on Google?

Click Get Backup Verification Codes. Copy one of the verification codes. Send the backup code to the user in an IM or text message. The user can sign in to their account using a password and the backup code.

Can a Google admin turn off 2-step verification for user?

Note: You can't turn off 2SV for a user if their account is suspended. If 2SV is enforced across your organization, the option to turn off 2SV for an individual user is disabled.

Is Google mandatory 2 factor authentication?

On October 5th, Google announced that it will make two-factor authentication (2FA), or two-step verification (2SV) as Google calls it, mandatory for over 150 million users.

Is there more than one authenticator app?

Yes, it is possible to have multiple authentication apps providing MFA to a single Microsoft 365 account. Yes, it is possible to achieve this with both Microsoft and third party authenticator apps.


1 Answers

I found this info in the Reporting API (of the Admin SDK).

Here's a snippet I just wrote:

function logUsers2step() {    
  var date = toISODate(new Date(Date.now()-3*24*60*60*1000));
  var reports = AdminReports.UserUsageReport.get('all', date).usageReports;
  nextReport: for( var r in reports ) {
    for( var p in reports[r].parameters )
      if( reports[r].parameters[p].name == 'accounts:is_2sv_enrolled' ) {
        Logger.log(reports[r].parameters[p].boolValue+' '+reports[r].entity.userEmail);
        continue nextReport;
      }
    Logger.log('not found '+reports[r].entity.userEmail);
  }
}

function toISODate(date) { return date.getFullYear()+'-'+pad(date.getMonth()+1)+'-'+pad(date.getDate()); }

function pad(number) { return number < 10 ? '0' + number : number; }

By the way, it seems you can have this report on the Apps Dashboard and can even enforce your users to do it.

like image 186
Henrique G. Abreu Avatar answered Oct 22 '22 03:10

Henrique G. Abreu