Find all Google Apps users who don’t use two-factor authentication

We implement two-factor authentication for all of our Google Apps users.

I wrote a script to list users in the Google Apps domain based on the sample provided by Google ( https://developers.google.com/apps-script/advanced/admin-sdk-directory#list_all_users )

I would like to filter this list by users who use or do not use two-factor authentication, but I can not find anywhere in the user API that allows me to do this.

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

+5
source share
1 answer

I found this information in the reporting API (from the admin SDK).

Here is the 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 that this report can be found on the application panel and even enforce your users .

+9
source

Source: https://habr.com/ru/post/1201556/


All Articles