How to prevent administrator privileges to open Password window

Hi Folks,

I am trying to check wheter a saved password has been changed since the last login with:



try
    do shell script "ls ~root" password pass with administrator privileges
on error
    set pass to ""
end try

While pass is retrieved from a file and is the adminstrator password… Are there any possibilities to solve this issue?

Thanks for any help…

Stefan

This seems very odd. What do you need to accomplish?

Hi Stefan,

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.

What means the ~root argument?

Hi Stefan,

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…)

Thanks for any help!

Stefan

Hi Folks,

something like this…

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

Thanks for your help!

Stefan

It is not possible to bypass the system authentification window, if an admin password fails

Hi Stefan,

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…

Thanks for your help!

Stefan