When In Doubt …

January 31st, 2007  |  Published in etc

… script!

The company’s got a new policy for passwords, and the company makes remote workers write in with requests for password changes due to some handwaving about not having the “bandwidth” to allow remote users to change their passwords via the VPN client. So I downloaded Mac Password Generator to handle the part about coming up with secure passwords.

It doesn’t have an Applescript dictionary, so you have to do UI scripting to get it to launch, set up the correct password type (mixed case, six characters, at least one number), generate the password and then copy the result to the clipboard, then it’s simple Applescript to generate the message in Mail.app and send off the password request plus bcc’ing an account to have a record.

Drop the resulting script in iCal, set it to go off every first Monday, and walk away.

Next up: fixing another Cisco VPN client annoyance with the magic of UI scripting, but we’re not documenting that.

Script after the jump …

Open this script in a new Script Editor window.

activate application "Password Generator"
tell application "System Events"
    tell process "Password Generator"
        set value of text field 1 of tab group 1 of window "Password Generator" to "7"
        select checkbox "A-Z" of tab group 1 of window "Password Generator"
        select checkbox "0-9" of tab group 1 of window "Password Generator"
        select checkbox "a-z" of tab group 1 of window "Password Generator"
        click button "Generate" of window "Password Generator"
        click button "Copy" of window "Password Generator"
        click button 1 of window "Password Generator"
    end tell
end tell

tell application "Mail"
    
    
    tell application "Mail"
        set myPass to the clipboard
        set theSender to "Michael Hall <xxx@xxx.xxx>"
        set myMailContents to "Hello," & return & return & "This is my bimonthly request for a new VPN password. Please set the password to: " & return & return & myPass & return & return & "Thanks! " & return & return & "-Michael" & return & "xxx.xxx.xxxx" & return
        
        set newMessage to make new outgoing message with properties {subject:"VPN Password Request", content:myMailContents}
        tell newMessage
            set visible to true
            set sender to theSender
            make new to recipient with properties {name:"JUPM User Support", address:"xxx@xxx.xxx"}
            
            make new bcc recipient with properties {name:"Michael Hall", address:"xxx@xxx.xxx"}
            activate
            
        end tell
        send newMessage
    end tell
    
end tell

</body>

Leave a Response