usually your syntax should work, but it differs from system version.
In Panther it works only with an admin user, in Tiger you can add user name “username”,
then it works also in a standard user.
hmm… the “ls ~root” means nothing - it is just a command which needs administrator privileges - if the command fails (because the previous entered password is incorrect now) then it should forward the user to enter a new password (instead of opening the build in password information…)
set pass_file to ((path to me as Unicode text) & "Contents:Resources:pass.txt") as file specification
repeat
try
set pass to read pass_file as string
on error
set pass to ""
end try
try
do shell script "ls ~root" password pass with administrator privileges
on error
set pass to ""
end try
if pass is "" then
repeat
set pass to text returned of (display dialog "Bitte geben Sie Ihr Administrator Passwort ein!" buttons {"Cancel", "OK"} default answer "")
set pass1 to text returned of (display dialog "Wiederholung der Passworteingabe:" buttons {"Cancel", "OK"} default answer "")
if pass is equal to pass1 then exit repeat
set pass_file to open for access pass_file with write permission
write (pass as string) to pass_file
close access pass_file
end repeat
end if
if pass is not "" then exit repeat
end repeat
I came to the same solution - I try to bypass this issue by using keychains…
first I have to enter a new keychain:
set theUserID to "labadmin"
set thePassword to "testpass"
tell application "Keychain Scripting"
launch
try
--unlock
set kc_Name to "testkey"
set kc_Account to theUserID
set kc_Password to thePassword
set kc_Description to "AppleShare password"
set kc_Comment to "This item was created by the buildKeys AppleScript"
make new AppleShare key with properties {name:kc_Name, account:kc_Account, password:kc_Password}
on error
--ErrorMsg
end try
end tell
Creating a User isn’t that difficult - but I have no clue on how to use the data with my application…