Problem with keychain, i dont' understand why, please help

Hi,

First, excuse my bad english from Paris :cool:
I have a strange problem with “Keychain Scripting” in an AppleScript Application. :confused:
So your experience is welcoming. Thanks by advance.

Here my code :

  1. Look for the password in keychain to get the password :

on getAccountAndPassword(keyname)
	
       set adminPass to ""

	startKeychainScripting()  -- Advice of Apple : http://docs.info.apple.com/article.html?artnum=301858
	
	tell application "Keychain Scripting"
                -- Here is my problem, application hang with an AppleEvent error timeout (-1712)
		try
			set theKey to first generic key of current keychain whose name is keyname
			set adminPass to password of theKey
		on error message number errNum
			display dialog message
		end try
	end tell

       return adminPass
end getAccountAndPassword

  1. Function to update or create key in keychain

on makeKey(maj, keyname, myLogin, myPassword)
	
	startKeychainScripting()
	
	tell application "Keychain Scripting"
		-- Same problem AppleEvent timeout, what is the problem ????
		tell current keychain
			if maj then
				try
					set theKey to first generic key whose name is keyname
					delete theKey -- To impove by setting directly with new password when i'll find the problem
				end try
			end if
			make new generic key with properties ¬
				{name:keyname, account:myLogin, password:myPassword, comment:"Authentification du MediaPlayer9"}
			return result
		end tell
	end tell
	
end makeKey


I don’t see where is my error. I try to delete the keychain session, recreate it manually and reexecute the script without success.
I try all suggestion about keychain on this forum… and it’s always ko. Do you have any idea ?

Thank you very much for your help on this problem. :slight_smile:

Gaëlle :wink:

Model: PowerBook PPC G4
AppleScript: 1.10.7
Browser: Firefox 1.5.0.7
Operating System: Mac OS X (10.4)

For testing, I simplified the script in Script Editor to:


tell application "Keychain Scripting"
	-- Here is my problem, application hang with an AppleEvent error timeout (-1712)
	local lstKeyChains
	set lstKeyChains to every keychain
	return lstKeyChains as list
end

Examingin the Events log, I see the following:


tell application "Keychain Scripting"
	get every keychain
		current application
		"Keychain Scripting kreeg een fout: AppleEvent time-out."

To me that suggests that applescript can’t resolve what is meant by “current application”. I don’t know enough about Keychains to know what might be expected, but that might be a direction to explore.