Re: Removing a Keychain Item
Re: Removing a Keychain Item
- Subject: Re: Removing a Keychain Item
- From: John Baltutis <email@hidden>
- Date: Thu, 29 Dec 2005 17:24:50 -0800
On 29 Dec 2005, Jim Mitchell <email@hidden> wrote:
>
> I'm trying to remove a keychain item (a generic key) that has been tested and
>determined incorrect due to the user changing their account password. The code
>is to be used in an AS Studio Project, but since the question is more AS
>related than ASS, I'm posting here instead of the "other" list.
>
> I've tried several variations, but just can't seem to come up with the right
>syntax. I'm hoping some kind soul might have a solution. The Dictionary for
>the Keychain Scripting App simply gives "delete reference" as a term, so when
>I attempt the following:
>
> property theKey : "myApp"
>
> tell application "Keychain Scripting"
> set keyList to (name of every generic key of current keychain)
> repeat with x from 1 to (length of keyList)
> if item x of keyList is theKey then
> delete (key theKey)
> -- also tried "delete (the key whose name is theKey)"
> exit repeat
> end if
> end repeat
> end tell
>
> I either get an "Access not allowed" error, or "Can't get key..." error
>depending on what I'm trying. Any takers?
After a few trials, I saw this in the event log on my system:
tell application "Keychain Scripting"
get every generickey of current keychain
{generic key 1of keychain "login.keychain", generic key 2 of keychain
"login.keychain"}
Thus, this works, using the same structure and substituting my key's name for
your key's name:
property theKey : "myApp"
tell application "Keychain Scripting"
set keyList to every generic key of current keychain
repeat with x from 1 to (length of keyList)
if the name ofitem x of keyList is theKey then
delete generickey x of current keychain
exit repeat
end if
end repeat
end tell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden