How can I run a shell script with admin privileges from Applescript? I am writing an Applescript that aims to automate the install (add to root keychain) and 'Always Trust' setting by simply launching the Applescript. I'm stuck with how to get the admin user authenticated with the authentication popup?

Here is my code so far:

try
    set question to display dialog "To Install Click 'Continue'" &amp; return &amp; "You will be prompted to enter an administartor password!" buttons {"Close", "Continue"} default button 2
    set answer to button returned of question
    if answer is equal to "Continue" then
        do shell script ("sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/Desktop/MyWiFiCertificate.crt")
    else if answer is equal to "Close" then
        display dialog "You have cancelled the WiFi Certificate installation." buttons {"Exit"} default button 1
    end if
on error errorMsg
    display dialog errorMsg
end try


However, I get this error

sudo: no tty present and no askpass program specified".


I'm guessing it is because of the fact that the operation can not be authenticated by the admin user. I'd be grateful if anyone who has automated this process before could refine my code to enable the user to authenticate and automatically 'Always Trust' the WiFi Certificate.
You can pass administrator privileges to a line of AppleScript which requires administrator privileges by appending "with administrator privileges":

do shell script "security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/Desktop/MyWiFiCertificate.crt" with administrator privileges