Solved

Lock/logoff/disable Apple Mac if network cable unplugged

Posted on 2010-11-08
6
668 Views
Last Modified: 2012-06-27
Can anyone think of a way to lock/logoff/disable an iMac when the network cable is unplugged or it loses network connectivity?

Our students unplug the network cable in an effort to stop remote control and avoid managed preferences.

Running OSX Snow Leopard

Any help/ideas appreciated!

0
Comment
Question by:Elthamtech
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:sweetfa2
ID: 34091688
http://tech.inhelsinki.nl/locationchanger/

The above link shows you how to launch a process when network status changes.  You can then launch a script to do what you want using launchctl when the network status goes to down - and likewise restore everything when they plug it in again.
0
 

Author Comment

by:Elthamtech
ID: 34098505
I am fairly new to the Mac world...Do you think you could please explain to me how that works?
0
 
LVL 17

Accepted Solution

by:
sweetfa2 earned 500 total points
ID: 34185921
The script in question does a lot of things, you won't need to do much of them.

You need to add the plist changes to your LaunchAgents directory.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>YOURInfo</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Shared/bin/locationchanger</string>
	</array>
	<key>WatchPaths</key>
	<array>
		<string>/Library/Preferences/SystemConfiguration</string>
	</array>
</dict>
</plist>

Open in new window

You need to create a script (which the plist actually refers to - referring to a script you create).  The one in the example is overly complex for what you want.

The script just needs to lock the computer.

There is the script below taken from http://hintsforums.macworld.com/archive/index.php/t-30274.html
#!/bin/sh

# This script uses Panther's "Fast User Switching"
# to switch to the user whose username is specified as a command-line arg.
# If no arg is specified, it brings up the login window.
#
# Based on a script on the MacOSXHints site:
# http://www.macosxhints.com/article.php?story=20031102031045417

MENUEXTRAS="/System/Library/CoreServices/Menu Extras"
CGSESSION="$MENUEXTRAS/User.menu/Contents/Resources/CGSession"

if [[ -z $1 ]]; then
"$CGSESSION" -suspend
else
USERID=`id -u $1`;
if [[ -z $USERID ]]; then
exit -1;
fi;
"$CGSESSION" -switchToUserID $USERID
fi;

Open in new window

0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:Elthamtech
ID: 34201827
The second script says there's a syntax error somewhere on this line:

if [[ -z $1 ]]; then

Expected “,” or “]” but found unknown token.
0
 
LVL 17

Expert Comment

by:sweetfa2
ID: 36469680
if [[ -z "$1" ]]; then
0
 

Author Comment

by:Elthamtech
ID: 36470637
All good - cheers I sorted that out. Took a while to get back to it,  but when I did your posts helped!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes in detail how to set up the iPad in the Enterprise using iPCU aka iPhone Configuration Utility.  This could also be used for the iPhone although I have not detailed out any differences. Preparation as an iPad Administrator:…
Create a default user profile for Mac OS X 10.7/10.8 Create a user account on OS X that will be a template for every other user of that computer. I usually call it “profile” and make it an administrator account for the time being. 1. Install a…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question