I'm looking for a way to have the system auto-logout if the screen is unlocked by an administrator. So if User1 is logged in and an admin unlocks the screen, User1 is logged out. This is enterprise standards that have to be met, something about security with more than one user logged in. (Windows does it so now Macs are expected to do so as well).

If FastUserSwitching is enabled, is there a way to have a login script check how many users are logged in and to log out (or restart) if more than one are? I've tried messing around with the USERS and LOGNAME commands but they don't seem to work in a shell script like they do with direct input in terminal.

It'd be best to achieve this without any third party apps and only with scripts.

Anyone have any ideas? I had posted this on the Apple Discussions with zero success.