Search code examples
applescriptprivilegesfinder

User properties/ privileges in AppleScript


I want to write an applescript program that first checks to see if the user has Admin privileges, and if it doesn't then requesting a re-log-in or something.

Eventually the script is going to need to do a sudo chmod of a folder I just created... I can do that with a do script and a with Administrator Priviledges.

However I haven't figured out how to either request admin privs for an applescript command, or even just check if the user HAS admin privs.

Anyone know? or at least point me at a GOOD applescript ref? (Apple.com reference is not helping me)

thanks.


Solution

  • A solution from the Apple forum:

    if ("80" is not in (do shell script "id -G")) then
       Error....
    

    seems to do the trick. It's hard to read, and as Philip Regan said, I'm doing it via the command line, but it seems to give me the protection that I need...