OS X Mount Active Directory Home Drive Automatically (Working Solution for OS X 10.10)

Prior to OS X 10.9 Mavericks here at the college we would use the option in the "Directory Utility" app to mount the Active Directory home drives. This was done by checking off "Use UNC path from Active Directory" but with OS X 10.9 Mavericks & OS X 10.10 Yosemite there was the adoptions of SMB2 which does not play well with Microsoft's version of SMB. We would have drives mounting but not the drives we wanted. We would normally want their home folder mounted as (ex. /studentname) but instead it was now being mounted as (ex. share/studentname). This is how we've been running for the past two years and haven't had much luck fixing it. 

Today with the help of a co-worker we were able to come up with an AppleScript that fixes this. Below is the simple script that I saved as an executable app and placed into the /Library/Scripts folder in our images. From here I added the app as a login item in the default profile. Once any user logs in the script would check to see what the users name is then look to Active Directory to poll what their Home Drive is. Next the script converts the backwards slashes "\" (used in the Windows World) to forward slashes "/" (Unix World) then mounts the drive. 

I've been testing this on a number of stations and now have it deployed out to some of our labs. 

If you want to use this script you need to make sure you go into "Directory Utility" and un-check "Use UNC path from Active Directory" since we no longer need this and now relying on this AppleScript to do the work.

In the script provided you will need to change "DOMAIN" to your campus domain. For an example our college it's just "CAMPUS".

Here's the script below to use or feel free to download it:

Download http://twistedmac.com/mount_aduser_home_drives.zip




set username to do shell script "whoami"

set homepath to do shell script "dscl '/Active Directory/DOMAIN/All Domains/' -read /Users/" & username & " | grep SMBHome: | cut -c 10- | sed 's/\\\\/\\//g' "

tell application "Finder"


            mount volume "SMB:" & homepath

      end try

end tell



When I have the free time I want to convert this into a .plist script to use with launch daemon instead of relying on an app in the login items to make it a little cleaner. Until then this will do the trick and something that I've been looking into for some time now without success. 

Hope this helps out others that have been looking for a similar solution.


Tags: apple, osx, script, applecript, deployment


Download Free FREE High-quality Joomla! Designs • Premium Joomla 3 Templates BIGtheme.net