Lock-out all non-admin users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2012 11:55 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2012 12:57 PM
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. 🙂