Mapping personal network home drives

New Contributor

Hello JAMF Nation Friends, I am a new administrator to the mac environment. I'm Looking to achieve a script that can be deployed or placed on a user's desktop that will map network drives and their personal home drive. The only issue i'm facing is that our windows infrastructure deploys our network drives and their personal network drive by log in vbscript. ( active directory home flied is blank ).

My question is, is it possible to deploy the user's personal home drive with the script calling for their active directory username e.g. smb:serverfolder%username% and what would be the best way to deploy the script so user's can run themselves.

Thank you in advance for all your help.


Contributor III

I use a modified version of this script.

I have added a variable for UID. Which I use in a ifelse statement. You can use this to map basically any network volume.

For user home drive mapping I have a policy set to run at login for users. Which defines variables $4 - $6. I use the same (or a slightly modified version of this script) to mount other network drive mappings with the variables ($4 - $6) defined for those network volumes. I clone those policies and make them available in Casper Self Service if for some reason a user needs to initiate them volume mount themselves.

My script looks like:


UID1=$(id -u $3)
    echo "UID: $UID1"
protocol="$4" # This is the protocol to connect with (afp | smb)
    echo "Protocol: $4"
serverName="$5"   # This is the address of the server, e.g.
    echo "Server: $5"
shareName="$6"    # This is the name of the share to mount
    echo "Sharename: $6"

if [[ "$UID1" -ge 1000 ]]; 
    then echo "User "$3" is an Active Directory account"
      # Mount the drive 
        mount_script=`/usr/bin/osascript  > /dev/null << EOT
        tell application "Finder" 
        mount volume "$protocol://${serverName}/${shareName}/$3"
        end tell
        echo "Logged in user is a local user"


This is a pretty common issue. It is not typically handled through casper, but instead through a locally stored and invoked script. Here are two examples:

1.) @bentoms developed an Applescript that does what you are looking for + more. If you only want to mount the home share, then the script becomes much shorter. His script attempts to mount shares based on AD group membership, which works well if there is a direct correlation between group membership and network share permissions. The script will throw an error to the end user if it tries to mount a share that the user does not have permission to access.

His script is called by LaunchAgent (important as it must be run as the user, not root) and is triggered by login.

2.) I copied some of his logic and wrote a bash script that performs similar functions, but also performs some additional checks. Mine does not utilize group membership to determine share privileges, it just tries to mount everything. I posted a copy of it on another thread here.

I chose to deploy my script using 2 launchAgents. One is triggered off of login, the other off of network state change. The second is not 100% reliable so I built a basic automator workflow that I placed in /Applications. All it does is invoke the script, but it looks like a normal application and is easily accessible to the user.

The network state launchAgent looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
            <string>sh /private/var/</string>

Valued Contributor II

in 10.11 the preferences.plist file does not change anymore. you might want to look at /var/db/dhcpclient/leases instead.