Home › Forums › OS X Server and Client Discussion › Active Directory › New (but really trying to learn) AD and Login Scripts
- This topic has 3 replies, 2 voices, and was last updated 16 years, 1 month ago by
Mad101daN.
-
AuthorPosts
-
December 8, 2008 at 11:19 pm #374945
Mad101daN
ParticipantHi
I would like to write a login hook, which would create the documents folder on the network home. Then set a flag so that it does not get recreated the next time. That user logs in.
I would like to do this so users, logging in through AD do not get the question mark in the dock where the documents folder is.
I do not have the use of a Mac server so no golden triangle setup.
I have read the “leveraging active direcroty on Mac OS x” which has been a great help, but I’m not sure how to write the scirpt.
So if anyone can be kind enough to point me in the right direction, I would really appreciate it.
Thank you
Dan
February 25, 2009 at 5:43 am #375557the_rug
ParticipantHi Mad101daN,
I think I know what you’re after, I’ve down the same myself.
I created a Bash script and it is set to run automatically as a login item.
Here’s what I did:
[size=9]#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH# Make sure that the user logging in is a network user with a local home
vTOP=`dscl localhost -read /Search/Users/$1 | grep OriginalNFSHomeDirectory | cut -d ” ” -f2 | cut -d “/” -f2`
if [ “$vTOP” = “Network” ]; then# Pull homeDir value from Active Directory
networkDir=`dscl localhost -read /Search/Users/$1 | grep OriginalHomeDirectory | cut -d “/” -f4 | cut -d “<" -f1`/`dscl localhost -read /Search/Users/$1 | grep OriginalHomeDirectory | cut -d ">” -f5 | cut -d “<" -f1` homeDir=/Volumes/$networkDir # Delete the unwanted folders (Desktop & Documents) rm -R -f "/Users/$1/Desktop" rm -R -f "/Users/$1/Documents" # Create the links to the user's network home drives ln -s "$homeDir/Mac Desktop" "/Users/$1/Desktop" ln -s "$homeDir" "/Users/$1/Documents" # Finish the loop started at the top of the script (important) fi[/size] [size=12][/size] So basically, the script checks to make sure the user has a network home drive first, then gets the homedir value, deletes the local folders 'Desktop' and 'Documents' from the user's local 'profile' (or home drive), then adds links in the profile folder to the user's network home drive. I linked the desktop as well so users could easily save things on their OSX desktop and they would be available on the network and when they login to other OSX machines. I hope this is what you wanted?!? Cheers, The_RugFebruary 25, 2009 at 5:46 am #375558the_rug
ParticipantOh, I forgot to mention:
The script cannot be run as a ‘login script’ because the context of the login script is run before the user is known, this means that the variable $1 is not known.
The script relies on this variable to know who has logged in…..
Hence it is run as a login item….
February 25, 2009 at 11:46 am #375561Mad101daN
ParticipantThx for your help.
Thats great I’ll give it a try 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed