1
-- Applescript to ask for username/password. repeats if incorrect.
repeat
-- Ask for user name
set userName to text returned of (display dialog "enter your user name" with title "User Name" default answer "" buttons {"Cancel", "Okay"} default button 2)
-- Asks for password
set myPassword to text returned of (display dialog "enter your password" with title "User Name" default answer "" buttons {"Cancel", "Okay"} default button 2 with hidden answer)
-- Sets users network share path
set userShare to "smb://" & userName & ":" & myPassword & "@ourserver/usershare/" & userName & ""
try
-- Attempts to mount the above location
mount volume userShare
-- This where the script pauses on the OSX connect to server prompt
--checks to see if users share is mounted in /volumes/
if " & userName & " is in (do shell script "/bin/ls /volumes") then
--exits loop
exit repeat
end if
end try
end repeat
我維護一個iMac實驗室,教師現在需要學生使用本地帳戶,但訪問其網絡共享。 iMac已加入Active Directory,但在這種情況下,孩子們正在以通用的本地「學生」帳戶登錄。蘋果腳本在連接到smb分享時檢查用戶名和密碼
我有一個詢問用戶用戶名和密碼的applescript,但只有在提供的用戶名和密碼都正確時纔有效。其他方面,當用戶名或密碼輸入錯誤時,「連接到服務器」提示將啓動。
我想看看是否有辦法來處理這個提示,或者如果輸入的用戶名不正確,可以完全跳過它。提示似乎現在基本上是「暫停」腳本。如果我按取消,腳本再次啓動,用戶可以重新輸入用戶名和密碼。
年輕的小學生正在使用它,所以限制錯誤對教師很有幫助。
任何想法?我認爲我正在尋找的是將證書傳遞給我們的服務器的方法,看看它們是否正確,然後嘗試安裝網絡共享。
我認爲問題是指令「掛載卷服務器」。字服務器沒有定義。你不會得到腳本錯誤,因爲你在'嘗試'區塊。我建議改爲「掛載音量UserShare」。 (UserShare在上面定義)。 – pbell
我對原始文件進行了一些編輯,使得這些名稱對於問題目的而言更通用一些,並且錯過了一個。編輯在這裏有正確的名稱。 –
自編輯以來,我現在按預期工作? – pbell