problem: deleting keychain object, access denied

hello everyone…

im currently messing around with my keychain and i have a problem: i want to delete a certain internet key but keychain scripting keeps giving me errors “access denied”.

here’s the script i’ve written:


tell application "Keychain Scripting"
	launch
	unlock current keychain
	set the_key to every Internet key of current keychain whose server is "..." and path is "..."
	delete Internet key the_key
end tell

there is exactly one key with these attributes and the name of the keychain is login.keychain.
i’ve read somewhere that the keychain file is readonly, so that could well be the problem.

can anybody please tell me how to delete the key or a workaround for the permissions on the keychain file?

thanks in advance,
jesta

p.s. os x 10.4.11

I don’t think you can delete from the Keychain from a script. You’ll have to go to the Keychain Access app, search for the key and delete it from there. You must be admin to do that, I think.

Hi,

The following works for me:

tell application "Keychain Scripting"
	launch
	unlock current keychain
	set the_key to every Internet key of current keychain whose server is "..." and path is "..."
	delete item 1 of the_key
end tell

the_key in your version of the script is a list of Internet keys. So if you say delete Internet key the_key you are taking a list (the_key) trying to make it into an ‘Internet key’ and then trying to delete that, which fails. Instead take the list returned and get the first item, which should already be an Internet key.

I am, however, an administrator on the machine, which as Adam points out may make a difference as to whether I can delete keys, but I have not tested that.

Best wishes

John Maisey
www.nhoj.co.uk