Skip to main content
Question

Create script for Mapping drive


Forum|alt.badge.img+6

Hi All
Could everyone help me to write a script that mapping the windows network share drive. That is when a user is BYOD and just run the script, the script will prompt for authentication and base on the username, the drive will map to correct share folder.
Thanks

6 replies

Forum|alt.badge.img+24
  • Valued Contributor
  • 1892 replies
  • August 7, 2012

Is this the drive defined in their AD object? (SMBHome?)


Forum|alt.badge.img+6
  • Author
  • Contributor
  • 14 replies
  • August 8, 2012

Hi Jarednichols

Yes there is and it is smb map share


Forum|alt.badge.img+21
  • Honored Contributor
  • 970 replies
  • August 8, 2012

Would an applescript help?

I use an applescript saved as an application and use mcx to have it as a login item.

It mounts all our standard network shares plus an extra share for our admins, a developer share if the user is a developer.


Forum|alt.badge.img+13
  • Contributor
  • 159 replies
  • August 8, 2012

If this BYOD device is being managed by your JSS, then you should be able to map the drive via MCX or Profile (vs. script).

The issue is to get the SMBHome (or NFSHomeDirectory) path for MCX/Profiles, the machine needs to be bound to your AD environment first. Then it will perform the dscl /Search -read /Users/whoami NFSHomeDirectory command for you. Else this will be a one-off script just for that one person and one machine.

If this is not being managed by your JSS, you are wanting to create the target folder first via mkdir /Volumes/MyShare then use smb_mount command.

- Justin


Forum|alt.badge.img+17
  • Employee
  • 43 replies
  • August 11, 2012

In fact I've just been working on something very similar... YMMV, but modify as required for your environment - we are using the AD plugin, just don't want to map to the SMB home as it's shared in a non-visible path and gives us a "?" in the dock....

#!/bin/bash

#Mount a users home directory outside of the AD Plugin UNC Path
SMBPATH=`dscl localhost read /Active Directory/DOMAINNAME/All Domains/Users/"$3" SMBHome | awk '{print $2}' | sed -e 's/\\\\\\/smb:///g' | sed 's:\\:/:g'`

#Make the users home folder and mount it...
#Get rid of remnants if there was previously an issue...
rmdir /Volumes/foldername
su $3 -c "mkdir /Volumes/foldername; mount -t smbfs -o nodev,nosuid $SMBPATH /Volumes/foldername"

#Place it in the Dock for the user
su $3 -c '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/foldername</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"'
#restart the Dock to make sure it's there
killall Dock

Forum|alt.badge.img+4
  • Contributor
  • 23 replies
  • August 11, 2013

Hi Andrina,
I'm new to scripting, are you still using this script to map users network drives? can you tell me the work flow when the a BYOD or Domain user first login?

Thank You,
Ariel


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings