Skip to content

Instantly share code, notes, and snippets.

@neilmartin83
Created June 3, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilmartin83/0425e4bb329ad07d0403 to your computer and use it in GitHub Desktop.
Save neilmartin83/0425e4bb329ad07d0403 to your computer and use it in GitHub Desktop.
#!/bin/bash
#Script to prevent login of users
#As of OS X 10.9 MCX- and profile-based methods for this do not seem to be working
#Code borrowed from https://jamfnation.jamfsoftware.com/discussion.html?id=4591
#Exclude authorised users and groups in the policy scope
user=$USER #Use existing Casper variable for user
heading=$'You are not authorised to use this facility.'
description=$'This is a specialist facility available only to selected students and staff within ADI.'
icon='/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarDeleteIcon.icns'
echo "$user is not authorised to use this Mac. Killing login session..."
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "$heading" -icon "$icon" -description "$description" -alignHeading centre &
sleep 10
killall jamfHelper
kill `ps -ef | fgrep loginwindow | grep -v grep | awk '{print $2}'`
exit 0
@neilmartin83
Copy link
Author

To be called by a Casper Policy that's scoped to all groups, excluding ones that are allowed to log in to the client. Or you could scope it to limit to users/groups you don't want to log in...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment