Map a file share to a folder with the current user's alias

cfullerton
New Contributor

Hey Everyone,
I have an existing file structure where the each of my users have a folder matching their Active Directory Alias. The folders are 3 folder into our file server.

Example:

SMB://Server/UserFolders/UserAlias
- UserAlias would be the currently logged in user.

Here's what I need:
When a user logs in, their personal folder is automatically mapped. The script or policy needs to be able to deploy to multiple people.
The script also needs to identify the current user's alias and map that folder by name

In my windows environment I use this as a bat login script:

Net Use Y: "serveruser drives%username%" /persistent:yes

The %username% will auto fill in the currently logged in user.

On my mac I try to "Connect to server" and use use the $USER and $WHOAMI but it errors out saying it cannot find the folder.

Some other details about my environment are below:
- We run Windows 2012 r2
- All computers in question have 10.10.3
- We have FireVault2 enabled
- All computers are joined to the domain

Can anyone help me?

Thanks!
- Jason

3 REPLIES 3

cfullerton
New Contributor

I've tried the following ways so far:

1st Try:
- Creating an alias shortcut using my AD alias
- Add it to Composer
- Created as DMG
- In the policy I added the "Fill existing user home directories" and "Fill user templates" options.

2nd Try:
- Created a new Configuration Policy
- Login Items
- Network Mounts
- Added "smb://server/users/$USER"

cbrewer
Valued Contributor II

If your computers are bound to AD and your users are in AD, how about just using the option in the AD plugin to "Use UNC path from Active Directory to derive network home location"?

There are lots of ways to do what you're looking for. We use a custom AppleScript app that runs at logon for every user. We also use dockutil to place smb shortcuts in the dock.

davidacland
Honored Contributor II
Honored Contributor II

I'm not sure if you mean your using the value stored in the SMBHome attribute in AD, or a hardcoded value. If it's the SMBHome, here's a link to our script https://github.com/amsysuk/public_scripts/tree/master/mount_SMBHome

If you are running it at login, you can use $3 instead of $USER.

If it's a static server path you can replace the variable that reads from AD with another value, but personally I'd recommend using SMBHome as it can edited from the windows server instead.

It would be worth doing a search on this forum as well as there's quite a few discussions about mounting drives that will have some useful info.