Advertisement
Guest User

Untitled

a guest
Jul 15th, 2009
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. property user_name : ""
  2. set user_name to "" # Added in because sometimes the script would magically remember the values of its last run despite being terminated?
  3. if user_name is "" then
  4.     set dialog_1 to display dialog "Please enter your username" default answer ""
  5.     set the user_name to the text returned of dialog_1
  6. end if
  7.  
  8. property pass_word : ""
  9. set pass_word to "" # Added in because sometimes the script would magically remember the values of its last run despite being terminated?
  10. if pass_word is "" then
  11.     set dialog_2 to display dialog "Please enter your password" default answer "" with hidden answer
  12.     set the pass_word to the text returned of dialog_2
  13. end if
  14.  
  15. property domain_name : "nr5project" # Change to your domain name (NOT FQDN, just domain name all lower case)
  16.  
  17. # By having this here we can include it via 'quote form of' to escape the with the double-escaped-backslashes ;)
  18. set awkParams to "{path = substr($NF, 4); gsub(/\\\\/, \"/\",path); printf path}"
  19. # By using 'set uncPath to(do shell script...)' we get the user of the double back slashing with the space in the dscl command and include our 'quoted form of'
  20. set uncPath to (do shell script "/usr/bin/dscl localhost read /Active\\ Directory/All\\ Domains/Users/" & user_name & " homeDirectory | awk -F: " & (quoted form of awkParams))
  21.  
  22. set command to "smb://" & domain_name & ";" & user_name & ":" & pass_word & "@" & uncPath
  23.  
  24. tell application "Finder"
  25.     try
  26.         mount volume command
  27.         display dialog "Your server folder has been mounted! Huray for technology"
  28.     on error
  29.         display dialog "There was an error mounting the Volume." & return & return & "The server may be unavailable at this time or you entered an incorrect username or password" & return & return & "Please inform somebody who has had wheatabix for breakfast if the problem continues." buttons {"Sorry sir"} default button 1
  30.     end try
  31. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement