I need to make a script that mounts (working with Active Directory here) the users network drive directory when then login. This is what I have so far and this part works, but I would like to some how incorporate a way of passing the login credentials to this script is possible. Anyway of passing this info?
tell application "Finder"
open location "smb://user:password@admcluster.domain.edu/Users/user"
end tell
Maybe this is better done as a shell script? Any info on that would be greatly appreciated too.
Thanks much
Dave
I’m not sure how to do that but there are other ways. For example to get a users name you can use this…
do shell script "whoami"
When I need a password for my scripts is use this handler. I found this somewhere on this website so I don’t know who to credit. It uses the Keychain to make password handling secure in applescript.
-- if you don't want to put your password in clear text in a script, then you can add your password in the Keychain Access application and use it from your script.
-- in Keychain access, click File>New Password Item..., give it a name, put your account shortname in account, and enter the password. Highlight it in the password list and under the Attributes button enter its kind as generic key. This is chosen because there aren't many of them and the search is much faster.
set keychainName to "keychain name" -- name of the keychain used in Keychain Access
set KeyName to "key name" -- name of the key
getPW(keychainName, KeyName)
on getPW(keychainName, KeyName)
tell application "Keychain Scripting"
launch
tell keychain keychainName
tell (some generic key whose name is KeyName)
set passwd to password
end tell
end tell
end tell
return passwd
end getPW