Lock-out all non-admin users

Riddel
Tera Expert

We have 3 instances (prod/test/dev) and I'd like to lock-out all non-admin users in test & dev. Is there any easy way to do so? Sounds like a routine script or option, but the only unhelpful reference to this is in the post-cloning checklist (User Access).

With 30000 users in our system, I need a quick way to lock-out users immediately after a clone.
Here is a script that lists all non-locked-out users, but includes admins. How can I omit admins from this list?


lockout_users();
function lockout_users() {
   var gr = new GlideRecord("sys_user");
   gr.addQuery('locked_out','false');
   gr.addQuery('user_name','!=','admin');
   gr.addQuery('user_name','!=','DiscoveryUser');
   gr.query();
   while (gr.next()) {
       if (!gr.hasRole('admin')) {
     //         gr.locked_out = true;
               gs.print(gr.user_name + ' - ' + gr.name + ' - ' +gr.locked_out);
               gr.update();
       }
   }
   gs.log("Completed locking out non-admin accounts");
}


Thanks,
Mac
5 REPLIES 5

Riddel
Tera Expert

And that's exactly what I need. Thanks so much Mark! Works great and now I don't have to mess with locking users out. 🙂