[MacTUG] Mapping a Network Drive at Login

Guillermo Fuentes gfuentes at uwaterloo.ca
Thu Mar 1 21:51:48 EST 2012


Hi Lowell,
In Arts we place a script called "Connect to my Nexus N drive" on the Desktop for users to mount their Nexus drive. The script also enables the "shows connected servers" on the Finder.

I'm including the code for two Apple scripts, the first one has the file server hardcoded (artsfile.uwaterloo.ca) for Arts students. The second one reads the home directory from Nexus.

It works fine on Snow Leopard. I haven't try this on Lion. 

Guillermo


(*********** 1st script: hardcoded file server ************)
(*
 Connects to Nexus N drive prompting for the user's password. 
*)

tell application "Finder"
	try
		set username to do shell script "whoami"
		tell application "Finder" to mount volume "smb://" & username & "@artsfile.uwaterloo.ca/" & username
	on error errtext number errnum
		if errnum = -55 then
			display dialog "Your Nexus N drive is already mounted"
		else
			display dialog "Coudn't connect to your Nexus N drive"
		end if
	end try
	open window of Finder preferences
	set current panel of window of Finder preferences to General Preferences panel
	set desktop shows connected servers of Finder preferences to true
	close window of Finder preferences
end tell
(*********** end hardcoded file server ************)


(***********  2nd script: file server from Nexus home directory ************)
(*
 Connects to Nexus N drive prompting for the user's password. 
*)
tell application "Finder"
    try
        set username to do shell script "whoami"
        set homedirectory to do shell script "ldapsearch -LLL -H ldap://ursa.nexus.uwaterloo.ca -b 'dc=nexus,dc=uwaterloo,dc=ca' '(&(objectClass=user)(sAMAccountName=" & username & "))' homeDirectory | grep 'homeDirectory:'|awk -F' ' '{print $2}' | sed -e 's/\\\\/\\//g'"
        
        tell application "Finder" to mount volume "smb:" & homedirectory
    on error errtext number errnum
        if errnum = -55 then
            display dialog "Your Nexus N drive is already mounted"
        else
            display dialog "Coudn't connect to your Nexus N drive"
        end if
    end try
    open window of Finder preferences
    set current panel of window of Finder preferences to General Preferences panel
    set desktop shows connected servers of Finder preferences to true
    close window of Finder preferences
end tell

(*********** end file server from Nexus home directory ************)



From: mactug-bounces at lists.uwaterloo.ca [mactug-bounces at lists.uwaterloo.ca] on behalf of Donald Duff-McCracken [dsmccrac at uwaterloo.ca]

Sent: Thursday, March 01, 2012 11:59 AM

To: Lowell Williamson; MacTUG

Subject: Re: [MacTUG] Mapping a Network Drive at Login













Hi Lowell





I usually get the user to connect to the server manually (under the Go menu) and get them to click 'remember password in keychain' or however it is worded. Then your solution should work.





So if I would want it to autologon, I would do these steps: 

as the apple article states, it is probably a good idea to have the connected servers show up on the desktop (so people do not get confused) so I would click that on in Finder preferencesMount the network share using Go>Connect to ServerClick the remember password in keychain buttonGo to System Preferences>User & Groups>username>login itemsAt this point I probably would not drag the whole share into the window. I would open the share (called 'Users' in this case) and then find the username I wanted and drag it into the window as described in the apple doc you linked to.I wish the 'hide' button would not cause the window to open all the time on login, but maybe that is what you want.

An alternative if you have people that do not want it always auto logging in is that you could drag the users folder on the share down onto the dock — it has to be on the 'folder' side of the dock (to the right of the little dotted line). That way when
 they want to connect the user name and password that is saved in the keychain is used to mount the connection.





It is probably better that a user is set to auto login and it probably is good that it pops into their face every time they log in. It is probably not a bad idea however to make an alias of their account on the share and put it on the desktop. It is an
 easier way for them to navigate to their directory than scrolling through all the users on the network share.





don











------------------------------------

Donald Duff-McCracken 

Technical Services Manager

Mapping, Analysis & Design

Faculty of Environment

University of Waterloo

(519) 888-4567 x32151

http://www.environment.uwaterloo.ca/computing/people/don.html

------------

To request help from MAD please us Request Tracker. For info see: http://www.environment.uwaterloo.ca/computing/faculty_staff/

------------

This email communication is intended as a private communication for the sole use of the primary addressee and those individuals listed for copies in the original message. The information contained in this email
 is private and confidential and If you are not an intended recipient you are hereby notified that copying, forwarding or other dissemination or distribution of this communication by any means is prohibited.  If you are not specifically authorized to receive
 this email and if you believe that you received it in error please notify the original sender immediately. 
















From: Lowell Williamson <llwillia at uwaterloo.ca>

Date: Thu, 1 Mar 2012 16:35:21 +0000

To: MacTUG <mactug at mailman.uwaterloo.ca>

Subject: [MacTUG] Mapping a Network Drive at Login








<!--
@font-face
	{font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline}
span.EmailStyle17
	{font-family:"Arial","sans-serif";
	color:#595959}
@page WordSection1
	{margin:72.0pt 72.0pt 72.0pt 72.0pt}
-->





Hi,
 
I’m trying to have our standalone MAC users map their N: drive automatically at login. The path to N: is
smb://fileu.uwaterloo.ca/users$/%username%. I’ve tried adding it to the Login Items as per,

http://support.apple.com/kb/HT4011, but it won’t pass the username and password. I’ve also tried it using the mount command but with no luck.

 
Does anyone have a fix for this?
 
Thanks.
--
Lowell
_________
 
______________________________
Lowell L. Williamson
AHS IT Specialist
University of Waterloo
BMH 2111 ext. 32326
______________________________
Check out the

AHS Computing Facebook Page
 



_______________________________________________ MacTUG mailing list 
MacTUG at lists.uwaterloo.cahttps://lists.uwaterloo.ca/mailman/listinfo/mactug






More information about the MacTUG mailing list