Hi all,
I’m forced to revise a script I wrote to mount network volumes shared on our Windows servers because Lion changes the way smb works. You can no longer mount folders in subdirectories of a Windows share without having at least read privileges on the folders containing the subdirectory you hope to mount as a volume on your desktop.
The workaround Apple recommends is to use mount_smbfs which still behaves the old (pre-Lion) way. So here I am trying to write a script that uses a shell command to mount the drive.
I got it to work fairly well, have managed to prompt for a password, save it in an application keychain, and then use it the user account and password info from the keychain on subsequent tries (at least that’s the plan.)
But. When it comes time to actually mount the drive, I hit a "permissions error’ that appears to be related to the folder I’m trying to mount the share to. If I use “with administrator privileges” to mount the volume, it no longer reports that error, but the server returns an “authentication error.” It’s almost as though it’s trying to pass “root” credentials to the server instead of the user name and password.
Anyway, here’s the code in question:
set varString to false
set AcctName to to do shell script "whoami"
set AcctPassword to ""
if varString is false then
set AcctPassword to text returned of ¬
(display dialog "Please enter password for " & AcctName ¬
default answer "" buttons {"Continue"} default button 1 with hidden answer)
do shell script "mkdir /Volumes/" & AcctName -- create folder to mount share to
do shell script "chmod 775 /Volumes/" & AcctName user name AcctName password AcctPassword -- try to give user rights to mount to this folder
do shell script "mount -v -t smbfs //server.domain.tld/vRoot/MP02_V006/HQ-ITS_Users/" & AcctName & " /Volumes/" & AcctName & " >2$1" user name AcctName password AcctPassword with administrator privileges
Without the “with administrator privileges” it returns:
error "sh: 2: Permission denied" number 1
with it, it returns an authentication error from the server.