Posted on 05-10-2021 06:54 AM
I'm running into an interesting issue in getting network drives mapped. At the university I work at we're using each individuals SID to map their network drives so:
storage/homes/SID
I've modified the below script for our environment,
logProcess="shareConnect"
userName="${3}"
protocol="${4}"
serverName="${5}"
shareName="${6}"
writelog ()
{
/usr/bin/logger -is -t "${logProcess}" "${1}"
if [[ -e "/var/log/jamf.log" ]];
then
/bin/echo "$(date +"%a %b %d %T") $(hostname -f | awk -F "." '{print $1}') jamf[${logProcess}]: ${1}" >> "/var/log/jamf.log"
fi
}
echoVariables ()
{
writelog "Log Process: ${logProcess}"
writelog "User: ${userName}"
writelog "Protocol: ${protocol}"
writelog "Server: ${serverName}"
writelog "Sharename: ${shareName}"
}
checkUsername ()
{
# Checks if the username variable is empty (user running script from Self
# Service)
if [[ -z "${userName}" ]];
then
userName=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");')
fi
}
mountShare ()
{
mount_script=`/usr/bin/osascript > /dev/null << EOT
# tell application "Finder"
activate
mount volume "${protocol}://${serverName}/${shareName}"
# end tell
EOT`
exitStatus="${?}"
}
echoVariables
checkUsername
mountShare
writelog "Script completed."
My question is has anyone out there ever used SID's to map network drives on a Mac? I've been trying everything I can think of to get this to work and am totally frustrated right now. Thank you in advance!!!
Posted on 05-29-2021 07:42 PM
you can try this function and see if it works for you:
mount_share () {
osascript <<EOF
set serverName to "ServerName.company.org"
set sharedResource to "ShareName"
set serverPath to ((path to startup disk as text) & "Volumes:" & sharedResource & "")
tell application "Finder"
if not (exists folder serverPath) then
mount volume "smb://" & serverName & "/" & sharedResource
else
return "" & sharedResource & " already mounted"
end if
end tell
EOF
}