Here s another alternative solution which no one mentioned yet.
The dscl command allows you to perform a variety of Directory Service tasks
and one of them is the ability to look up a user s account type.
The command: dscl . read /Groups/admin GroupMembership
will list all admin
accounts on OS X.
So if you wanted to incorporate that into an AppleScript you could do the following:
set userName to "whatever username you wanted to check"
set readAdminGroup to do shell script "dscl . read /Groups/admin GroupMembership"
set AppleScript s text item delimiters to " "
set adminNames to text items of readAdminGroup
--loop through Admin Group to check if username exists
repeat with i in adminNames
if adminNames does not contain userName then
set isAdmin to false
else
set isAdmin to true
end if
end repeat
return isAdmin
Once you find out whether the variable isAdmin is true or false you can then
perform a variety of functions. Also, if the script was being deployed or sent through ARD you could set the userName variable (the first line in the above script) to check for the current user with a whoami command. So the first line would then look like this:
set userName to do shell script "whoami"