Mount Hidden Network Home

Contributor III

We've run into an issue with the AD Plugin and mounting of network homes that do not have a directly visible path to the folder (but do have traverse rights). I ended up writing this with the help of Apple and Googling. I wanted to share it here in case you have run into a similar problem.

This will attempt to mount the folder marked in AD as your network home folder. If you already mounted it, it should just open the share. If you haven't mounted it yet, it will mount it for you. I did this as an Applescript so the user could click on something with a cute icon and not have a window hanging around after (nor effect their user of Terminal).

set short_name to system attribute "USER"
set UserNetHome to do shell script "dscl . read /Users/$USER SMBHome | awk '{print $2}' | tr '\' '/'"
set UserNetHomeMountInfo to do shell script "dscl . read /Users/$USER SMBHome | awk '{print $2}' | tr '\' '/' | sed -e 's|//||g'"

set UserNetMountPath to every paragraph of (do shell script "mount -d -v | grep " & UserNetHomeMountInfo & " | awk -F ' on ' '{print $2}' | sed -e 's| (.*||g' 2> /dev/null")

if UserNetHome is {} then
end if

tell application "Finder"

    if (UserNetMountPath is {}) then
        open location "smb:" & UserNetHome
        open disk UserNetMountPath
    end if
end tell