• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting password of a keychain key
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting password of a keychain key


  • Subject: Re: Setting password of a keychain key
  • From: kai <email@hidden>
  • Date: Tue, 28 Mar 2006 20:55:47 +0100


On 28 Mar 2006, at 14:02, Stephen Jonke wrote:

I am having trouble scripting Keychain Scripting. The following works fine:

tell application "Keychain Scripting"
tell keychain 1
unlock
set theKey to (first key whose name is "Some Key")
set password of (first key of keychain 1 whose name is "HST VPN") to "SomePassword"
end tell
end tell


However, the following does not work:

tell application "Keychain Scripting"
tell keychain 1
unlock
set theKey to (first key whose name is "Some Key")
set thePassword to text returned of (display dialog "Enter new password" default answer "" with hidden answer)
set password of (first key of keychain 1 whose name is "HST VPN") to (thePassword as string)
end tell
end tell


It gives an error at the "set password" line. I've tried casting the entered password to "Unicode text", to "International text" and to "string", as well as not casting. Nothing seems to work. Has anyone gotten this type of thing to work?

Keychain Scripting evidently requires plain text, Steve - which helps to explain why your first version works and your second doesn't. (The text returned from display dialog is Unicode text. Even after the coercion to string, it still contains some embedded style data that causes Keychain Scripting to choke.)


Try changing the line that sets the variable 'thePassword' to:

---------------------

set {text:thePassword} to text returned of (display dialog "Enter new password" default answer "" with hidden answer) as string

---------------------

(Incidentally, I'd be tempted to place this line before the application tell block, rather than inside it.)

---
kai


_______________________________________________ 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
  • Follow-Ups:
    • Re: Setting password of a keychain key
      • From: "Adam Bell" <email@hidden>
References: 
 >Setting password of a keychain key (From: Stephen Jonke <email@hidden>)

  • Prev by Date: RE: Converting Unix path to AppleScript path
  • Next by Date: Re: Setting password of a keychain key
  • Previous by thread: Re: Setting password of a keychain key
  • Next by thread: Re: Setting password of a keychain key
  • Index(es):
    • Date
    • Thread