Если ваш Mac работает под управлением Leopard (Mac OS X 10.5+), вы можете использовать свойство long user name
команды system info
, которая возвращает полное имя текущего пользователя. Сказав это, вы могли бы сделать это ...
set the current_user to (get the long user name of (system info)) as string
set the input_password to the text returned of (display dialog "Please enter the password for " & the current_user & ":" default answer "" buttons{"OK"} default button 1 with hidden answer) --The user cannot bypass this dialog.
--The 'hidden answer' property, when true, changes every character you type in the dialog box into ◘'s.
try
--This next line will verify that the password entered matches the current user's password.
do shell script "history -c" user name the current_user password the input_password with administrator privileges
on error --incorrect password
display dialog "Sorry. You entered the wrong password." buttons{"Cancel"}
end try
--Put whatever you want to do after authentication here.
Если у вас есть какие-либо вопросы, просто спросите меня:)