Solved

Lock/logoff/disable Apple Mac if network cable unplugged

Posted on 2010-11-08
6
665 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now