Through looking at other posts I've come up with this script which works fine when run from a terminal.
I replace $3 with $USER when I run from terminal.
#!/bin/sh
currentuser=$3
smbhome=`dscl '/Active Directory/CSUMAIN/All Domains' -read /Users/$currentuser SMBHome | awk '{print $2}' | sed -e 's/\\\\\\/smb:///g' | sed 's:\\:/:g'`
echo $smbhome
if [ $? != "0" ] ; then
echo could not get smb home. Offline?
exit
fi
if [ "$smbhome" == '' ] ; then
echo could not get smb home. Not defined for user $currentuser?
exit
fi
#Make the users home folder and mount it...
#Get rid of remnants if there was previously an issue...
rmdir /Volumes/$currentuser
mkdir /Volumes/$currentuser
mount_smbfs $smbhome /Volumes/$currentuser
#Place it in the Dock for the user
defaults write com.apple.dock persistent-others -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Volumes/$currentuser</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"'
#restart the Dock to make sure it's there
killall Dock
exit 0
When I set it up to run through a policy at login I receive a "Script result: dsRecTypeStandard:Users" message and then a URL parsing failed error with mount_smbfs.
I've tried using the $USER variable with similar results.
I'm logging in as a network user not a local account.