Mac OSX auto mount user's network drive

  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post September 6th, 2006, 10:30 pm

Hey, so we have a server running Windows Server 2003 setup with Active Directory login. The Macs can login to the server using the AD login, but with all of the users on the Windows XP computers, the My Documents folder gets mounted to the users H: drive on the network. How could this be done on the Macs? OS X v10.4.2
thanks :]
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 6th, 2006, 10:30 pm

  • STeeLRaT
  • Graduate
  • Graduate
  • User avatar
  • Joined: Mar 17, 2006
  • Posts: 183
  • Loc: somewhere
  • Status: Offline

Post September 15th, 2006, 11:41 am

http://www.Google.com

EDIT: I think this question is to hard. Googling will go faster than waiting for someone with a serious answer. This could take a couple week. If it's not a case of life or death you should just wait.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post September 15th, 2006, 12:45 pm

STeeLRaT wrote:
http://www.Google.com


did you HONESTLY just suggest google?
lmao

i'm not an idiot...
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • bleepnik
  • Professor
  • Professor
  • User avatar
  • Joined: Feb 14, 2004
  • Posts: 971
  • Loc: South Jersey, US
  • Status: Offline

Post October 15th, 2006, 11:00 am

Did you ever figure this out? If not, can you rephrase what you're trying to do? I'm not sure I get it. Are you just trying to automatically mount a shared network volume when a (Mac) user logs in?

.g
  • teemilk
  • Born
  • Born
  • No Avatar
  • Joined: Nov 17, 2006
  • Posts: 1
  • Status: Offline

Post November 17th, 2006, 1:09 am

This is my apple script for Map Network Drive

Code: [ Select ]
set user_name to last word of (path to current user folder as text)
tell application "Finder"
    try
        mount volume "smb://" & user_name & "@server/" & user_name & ""
    end try
end tell
  1. set user_name to last word of (path to current user folder as text)
  2. tell application "Finder"
  3.     try
  4.         mount volume "smb://" & user_name & "@server/" & user_name & ""
  5.     end try
  6. end tell


1. You have to save as application.

2. Set it run everytime you logon computer by Go to system preferences -> accounts -> Login item

3. Copy com.apple.LaunchServices.plist and loginwindow.plist from /Library/Preference of your home folder account to /systemx/library/user template/English.lproj/Library/Preference.

4. Logon to AD Domain by Domain Account it with map drive with share as username of that account.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post November 17th, 2006, 4:39 am

why thank you very much..

i will give that a try and repost with its results :]
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • dlegend
  • Born
  • Born
  • No Avatar
  • Joined: Mar 25, 2007
  • Posts: 1
  • Status: Offline

Post March 25th, 2007, 2:19 pm

I'm sure the applescript option is great, but the simple way is to just drag the drive to the "log in items" of the "Users" pane in "System preferences".
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post March 28th, 2007, 11:07 am

dlegend wrote:
I'm sure the applescript option is great, but the simple way is to just drag the drive to the "log in items" of the "Users" pane in "System preferences".

yeaa.. THATS going to work for 5,000 users who all haven't logged in to the computer yet, but might. and it wouldn't even be remotely time consuming..



for some reason whenever i try the script stated here and i try to add it to login items to any user NOT root, the accounts window basically freezes. if i drag another window over and off of it it will show me the login items window, except it'll still be frozen and it wont have any buttons. arg :(
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • gutter
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 23, 2007
  • Posts: 5
  • Status: Offline

Post July 23rd, 2007, 2:12 pm

Hey, don't know if this thread is still active but here's what you want to do, you want to create a login hook (if you don't know what it is Google it! There's ton of info out there about it including a gui called iHook) which is a shell script that run at login. The script itself will look something like this:

#!/bin/bash

mkdir /Volumes/<Share Name>
/sbin/mount -t smb smb://username:password@172.0.0.0/<Share Name> /Volumes/<Share Name>

This will mount the share with the given user name and password (for more information on the mount command type 'man mount' in the command line) at the mount point '/Volumes/<Share Name>' (which can actualy be anywhere you want but i like to keep OS conventions). Note, you probably want to set user name to 'guest' as there is no (thank god) variable floating around the operating system that contains the users password.
Also note, you have to give the full '/sbin/' address of mount, the only commands you can use in login scripts without giving their full path name are the ones in the '/bin' folder.
Okay, so save this file as something descriptive (like mapfolder.sh) and save it somewhere universal (I like /Library/Scripts/). When you're saving it, make sure it's in plain text format (so if you're using TextEdit to create it you'll have to go 'Format->Make Plain Text'), change the owner to 'root' and the make sure root has full access (in particular execute privileges):

(in command line type)

sudo chown root <Name Of File>
sudo chmod 700 <Name Of File>

Now we'll bind the script to the log in:

(in command line type)

sudo defaults write com.apple.loginwindow LoginHook /path/to/script/<Name Of Script>

And now, as long as you've done everything correctly, you should be golden. Restart and try logging in as a user (any user at this point, if you want to make the script more advanced and check if the user is local or not there are many good ways that can be found in other peoples scripts (in particular analyzing the Network Home Redirector script is fun and rewarding) but that is beyond the scope of what I'm trying to demonstrate here) and see if everything works. If not keep tweaking the script until its happy.

Finally I want to address some of the issues raised in the other posts:
The Applescript option is overkill in my experience (when OS X mounts a remote volume it does all kinds of background error checking and what not that i've found slow things down significantly) and the login items in the users Preferences are very hard to maintain with a large user base. If you do get something with applescript working you can always use osascript to port it to the command line and send it out via ssh, radmin, or any of a number of programs designed to help this kind of mass management. Finaly, the Login/Logout hooks are computer specific not user specific so you will have to deploy to every computer on the network and once again, without more functionality, it will run for every user who logs in.

Sorry about the state of my spelling, hope this helps everyone.
  • anilth
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Nov 15, 2007
  • Posts: 6
  • Status: Offline

Post November 20th, 2007, 6:29 am

Sounds your scripts is promising but one things is : I have a user home drive in samba, is there a way to modify this script so when user logs in they will get \\servername\username as a map drive and restart the machine as soon they logout. Perhaps it is possible by using login and logout hook. Can you point to this .
  • gutter
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 23, 2007
  • Posts: 5
  • Status: Offline

Post November 20th, 2007, 5:19 pm

Well, this should work just fine (unless I'm hideously mistaken samba is a SMB server), the variable $1 contains the user name of the current user in a shell script, beyond that its up to you to figure out how you want the process to work, where you want things to mount and if you want to share out each individual home directory, in which case you call is going to be something like:

/sbin/mount -t smb smb://username:password@172.0.0.0/$1 /Volumes/$1

(unix guys, let me know if this is syntacticly wrong, I'm not in a position to check it at the moment)

or if you want to share out the root folder containing the home directories and give users access to their individual folders some other way (not really recommended but there are situations in which it would work better). If you can clarify what exactly you're trying to do i could get a better idea of which direction to point you, besides of course o'reilly's OSX for Unix Geeks.
  • anilth
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Nov 15, 2007
  • Posts: 6
  • Status: Offline

Post November 21st, 2007, 11:22 am

hello gutter,

Thanks ! this is what I am trying to do- authenticate user AD - and when they logged in run the login script which will map their home drive in Desktop from like \\server\username. and when they logout run logout script to restart and unmount their drive (this is only because to bring up book picker menu). i manged to do logouthook, but following your instruction it doesn´t map the drive when user logs in. Note :

however if try to mapp manually by pressing apple key +k and do like smb://servername/username - supply username and password it does map. Which I don´t really want to do. It will be nice if mapping thing happens as soon as they login.

Thanks.

AT
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post November 22nd, 2007, 11:57 pm

you shouldn't need their AD username & password if the person is logged in to the computer with an AD account. do you have the computer joined to the domain?
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • anilth
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Nov 15, 2007
  • Posts: 6
  • Status: Offline

Post November 26th, 2007, 9:51 am

hello Anarch,

Yes, computer are joined the domain.

Rds,
A
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Joined: Oct 30, 2004
  • Posts: 2521
  • Loc: /usr/src/MI
  • Status: Offline

Post November 26th, 2007, 11:13 pm

hm..i dont recall whether or not the afp protocol needs to be enabled on the server, but either using smb or afp you as long as the user is logged on with an AD user account he/she shouldn't need to reauthenticate.. i.e. after logging on, if you go to connect to server and type: smb://your-server-address/folder OR afp://your-server-has-afp-enabled/folder it should bring up that folder without requiring authentication
Image
"In a world without walls and fences, who needs Windows and Gates?"
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 26th, 2007, 11:13 pm

Post Information

  • Total Posts in this topic: 26 posts
  • Users browsing this forum: No registered users and 15 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.