Here's mine. I run it as a "once per user" policy. It mounts their AD-defined home share and adds it to the Dock for future use. If they're on the wire and get a Kerberos ticket generated it'll mount when they click on it on the Dock. If they're offline and then VPN in (i.e. don't have a Kerberos ticket), they'll be prompted for creds if they click on it to mount it.
#!/bin/sh
# Filename: mountShares.sh
# Purpose: Mount file shares automatically with Kerberos ticket
# Author: Jared F. Nichols
#Find the logged in user
user=`ls -la /dev/console | cut -d " " -f 4`
#Find their P drive server
server=`dscl . -read /Users/$user | grep SMBHome: | cut -d '' -f 3`
#Set this temp string because 'defaults' is literal and won't resolve variables
tmpStr='<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Volumes/'$user'</string><key>_CFURLStringType</key><integer>0</integer></dict><key>showas</key><integer>2</integer></dict><key>tile-type</key><string>directory-tile</string></dict>'
#Mount the user's P drive
sudo -u $user jamf mount -server $server -share $user -type smb
#Write the P drive to the dock
sudo -u $user defaults write /Users/$user/Library/Preferences/com.apple.dock persistent-others -array-add $tmpStr
#Kick the Dock in the ass. Nothing else to see here, folks.
killall Dock
I believe just doing this will output the full path of the SMB home, not able to test, so please test.
dscl . read /Users/username SMBHome
Then just put that into a variable with the mount command, or the JAMF binary.
Hope this helps,
Tom
Ah that's a good one. Thanks
Or just use Jared's script haha. I did not see Jared replied to this, as I did not hit submit yet on here.
Cheers
tom
Your dscl lets me kill the grep though. :)
Ironically I just learned this attribute was even there on cached AD accounts. Professionally I haven't had to support a Windows server since 2004ish. I was always the guy that got stuck managing the Macs and Linux boxes. When I found this I was like, this is way easier than parsing XML...derp
:-)
Tom
This is what I do: http://macmule.com/2011/09/08/how-to-map-drives-printers-based-on-ad-group-membership-on-osx/
That way when people drop connection due to whatever, they can re-run the app & get their drives back.
Meh, not a fan of AppleScript, but to each his own. If it works for you, cool :)
Yea but if it does the job. :)
Gives the users something to press when they lose connection + runs as the user so uses their Kerberos ticket etc.
(oh & it's mostly bash in AppleScript anyways. :))
I do a combo- I have a script that mounts the user directory using a dscl query and a launchagent for automounting at login, and an applescript based GUI app that runs a slightly modified version of the BASH script for people who VPN in and don't have a corporate connection at login.
I do a combo- I have a script that mounts the user directory using a dscl query and a launchagent for automounting at login, and an applescript based GUI app that runs a slightly modified version of the BASH script for people who VPN in and don't have a corporate connection at login.
Hey Nick,
If you don't mind sharing with me I'd love to see this. I have got similar projects I am working on. You can send it to me via email if you don't want to post it here. Thanks in advance!
Tom