I have a pretty complicated problem here, and I’m not sure if Applescript can even do it as I have barely done any programming with Applescript before. I have an OSX server that has student accounts/network folders. The clients are 9.2.2. I want to create a program that when a student runs the program it will ask them for their Username and Password and if both are correct it will then mount their network folder on the desktop. Is this even possible and if so does anyone have any tips on how to do this? Thanks for all your help.
This should be very easy but just a few questions…
Will the 9.2 machine be connecting to the fileserver via tcp/ip or appletalk?
Will the name of the home folder be the same as the user’s name?
-john
I would like them to connect to the fileserver through TCP/IP and their network home folder will be the same name as their username.
Try this:
set theUname to text returned of (display dialog "User: " default answer "")
set thePWD to text returned of (display dialog "Password: " default answer "")
try
mount volume ("afp://" & theUname & ":" & thePWD & "@substitute.your.server's.ip.address.here" & theUname)
on error
display dialog "Couldn't connect to server, is your username and password correct?"
end try
Be aware though, that when they type their password it will be visible as they type!
HTH -john
i entered in the code you gave me and edited this one line…
mount volume (“afp://” & theUname & “:” & thePWD & “@serverip/Users/” & theUname)
I added the /Users/ because that is where all the student accounts are located. I ran the script, it prompted for the Username and Password and then all it did was mount the entire User sharepoint. Then when you open it it displays every user and then you just click on your user. Is there a way to get the specific Users folder to mount either by itself or along with the User sharepoint? Do you understand what I am trying to say? I don’t want to the the student have to open up the User’s sharepoint and search for their name. Thanks so far.
The sharepoints should be set on the server to allow the user to only see their folder when they log in.
It sounds to me like you have a group set on the server that has all the users inside it and the group is given permission to the users folder. The user would need to be restricted access to anything other than their folder at the server in order to make this work as you expect. However, barring that…
you can change this line to read as follows:
mount volume ("afp://" & theUname & ":" & thePWD & "@serverip/Users/"
tell application "finder" to open ("Users:" & theUname)
This would log on and at least open their folder for them without having to look for it.
HTH -john
Thanks for all your help so far. I really appreciate it. I will check the settings on the server tomorrow and let you know how things work out.
I can’t seem to get this to work. When I add in the last piece of code you suggested it doesn’t open the users folder. It mounts the Users sharepoint and then gives the Error message. I have tried everything I can think of. I tried opening the users home folder numerous ways but none have worked thus far. Any suggestions?
Piecing together several hints found on these boards, I came up with this:
tell application "Finder"
activate --bring the Finder to the front so dialogs aren't hidden
try -- check to see if volume is already mounted
set VolumeName to "Users" as string
set DiskList to list disks --get all disks currently mounted --unimportant if this is strictly a script that is run on startup
if DiskList contains VolumeName then
select VolumeName
eject VolumeName
end if
end try
end tell
login()
on login()
tell application "Finder"
activate
set txt_returned to text returned of ¬
(display dialog "Input your network username" default answer "" buttons ¬
{"Cancel", "OK"} default button 2)
if txt_returned is not "" then set char1 to first character of txt_returned
set user_name to txt_returned
mount volume "afp://xxx.xxx.xxx.xxx/Users/"
select folder user_name of folder char1 of disk "Users"
open selection
end tell
end login
This checks to see if the prior user is stilll logged in, then logs them out, then logs the next person in and opens their personal folder on the server. Now, if the path is different on your server you might have to change this script a bit. But this works for me, and we’re going to put it on all of our lab machines.