Novell Home

Student Login Versus Staff Login

Novell Cool Solutions: Trench
By Randall R. Saeks

Digg This - Slashdot This

Posted: 12 Jul 2004
 

PROBLEM: Distinguishing between staff and students logging in with OS X via LDAP and determining which location they are at.

SOLUTION: Using some unix commands, a loginhook was written to have the shell read the id of the user, as well as searching for the IP address of the server housing their home directory. This solution is based on the length of the user ID (with staff being 4 digits, and students 5 or 6) and the path of the home directory (either 10.2 for one building or 10.3 for another building), creating a desktop and items related to that user and that building. These values were obtained via LDAP from eDirectory.

Example

#/bin/sh

############################## desktop.sh ######################################
# Author    : Randy Saeks
#
# Purpose   : Run any items needed that are user related
# Calls     : /GBN/student.sh if UID > 9999 && $HOME contains 10.2
#	    : /GBN/staff.sh if UID < 10000 && $HOME contains 10.2
#	    : /GBS/student.sh if UID > 9999 $$ $HOME contains 10.3
#	    : /GBS/staff.sh if UID < 10000 && $HOME contains 10.3
# Revisions : 03/05/2004 (RS) - Script Created 
#             03/11/2004 (RS) - Added line to copy to an 'All Users' Desktop
#	      03/15/2004 (RS) - Added link to FacStaff on GBNCS2
#	      04/15/2004 (RS) - Added conditional statements to distinguish
#	                        between student & staff based on UID.
#	      05/28/2004 (RS) - Added IP checking for loation
###############################################################################

#### Variable Declarations ####
user_id=`id -u`

#### -= Actions Based on a student login or a faculty login =-

if [ `id -u` -le 9999 ]
then
	if echo "$HOME" | grep -q '10\.2'; then
		# -= Run the GBN Staff Script =-
		/Library/Management/GBN/staff.sh
		ditto -rsrc /Library/Management/GBN/All\ Users/Teacher\ Folders ~/Desktop
	elif echo "$HOME" | grep -q '10\.3'; then
		# -= Run the GBS Staff Script =-
		/Library/Management/GBS/staff.sh
		#ditto -rsrc /Library/Management/GBS/All\ Users/Teacher\ Folders ~/Desktop
	elif echo "$HOME" | grep -q '10\.1'; then
		# -= Run the ADM Staff Scripts =-
		echo "TEST"
	fi
elif	[ `id -u` -gt 10000 ]
then
	if echo "$HOME" | grep -q '10\.2'; then
		# -= Run the GBN Student Script =-
		/Library/Management/GBN/student.sh
		ln -shf /Network/Servers/10.2.1.22/gbncs3.data/Data/GBN ~/Desktop/Teacher\ Folders
	elif echo "$HOME" | grep -q '10\.3'; then
		# -= Run the GBS Student Script =-
		/Library/Management/GBS/student.sh
		ln -shf /Network/Servers/10.3.1.22/gbscs3.data/Data/GBS ~/Desktop/Teacher\ Folders
	elif echo "$HOME" | grep -q '10\.1'; then
		# -= Run the ADM Student Script =-
		echo "TEST"
	fi
fi

# -= Items pertaining to all users will be run here =-
ln -shf ~/ ~/Desktop/My\ User\ Folder
exit 0

If you have any questions you may contact Randy at rsaeks@gmail.com


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell