Applescript Authentication

Hi everyone. I’m fairly good with Applescript, although probally not very compared to many of you but anyway I was wondering if there is a way to make a authentication window come up with a prompt. I know of the display dialog command and the display dialog with icon note command but is there a way to make a authentication window instead of the two previuosly metioned?

I don’t know if there’s something you can do with a shell script to do it. It’s proabably just a few lines of C to call the system authentication. I don’t know how to do that, but you could check apple’s dev doc site.

If you want to create your own, have you played with AppleScript Studio at all? It lets you add very complex interfaces to your scripts. If you think that’s over your head, you could use FaceSpan, or just use straight scripting and ask the user to select a user name from “choose from list” and then put up a separate dialog to get the password.

The administrator authentication is a system-level device used by the system to protect itself. Yes, it can be accessed in coded applications, primarily by levels deeper than surface languages like applescript, though. As far as I know, it is not a scriptable object that you can easily manipulate and retrieve data from. Even if you did invoke the security server to display the window, it is a complex task to provide security criteria by which to measure the auth, and similarly complex to read the login info and verify auth.

In my opinion, these are good and important obstacles. When someone wants to trigger actual system authentication, I would wonder what exactly you’re creating and why you’d want to approach it that way… in an applescript. If I was to encounter an authentication request by an entity other than the system, it’d raise some red flags for me. If it’s a script for you, you shouldn’t mind a plain interface. If it’s for others, you probably owe them the honesty of scripting an interface that clarifies that YOU are requesting their admin info, not the system… and let them choose if they trust you to have that info. Besides, if the system needs genuine authentication, it will by default ask for it when required… that’s why it exists. :wink:

If you’re doing actions that require admin access, there are plenty of other ways to get the info, that do not require duping the system (or the user). If it’s a script for you alone, just hard-code it into the app. Also, as digest4d said, there are some other very fine options. Use a couple dialogs to request the info. It’s not pretty, but it does the job and can easily retrieve the info you’re looking for. Or, use applescript studio to create a custom interface that not only requests the info, but can be customized to be exactly like the auth login, or totally unique to express the flavor of your creation.

The auth window is not a generic window like a dialog. You can’t just pop it up whenever you’d like. It is a genuine tool used for serious business and should be treated as such, in my opinion.

j

Ok…that really didn’t help at all but ok. Oh and btw, can applescript studio be used with 10.2.8? thats what my G4 is running and I kinda want it.

Hi,

AppleScript Studio works well with Jaguar.

gl,

apple just changed things cause they wanted to sell their os

they didn’t realy need to do that.

gl,

ok thanks. ok so i’ve been working on that auth window thing and i can’t make anything past a dialog box apear. :frowning: anyway, i have decide to go for the next best thing and just use crappy dialog boxes but was wondering if there is a way to make the certain results of strings into dots. like they have on websites and stuff where the whole password is just dots instead of plain text. not sure if this is another system level thing but i would be a nice effect to have it do that.

It sounds like your projects are getting bigger than basic AS can provide for. As you’ve found, basic scripts are pretty limited in their UI resources. You’re probably not going to find an elegant (if any) solution to this problem without resorting to using ASStudio. Secure text fields are pretty easy in ASStudio. You drop a regular text field into your window, then in the custom class pane in the info window, select “NSSecureTextField”… and it’s all dots.

j

hmmm. yeah it sounds like I need to get “meself” a copy of applescript studio. I looked on apple for a download but couldn’t find one. does it only come with xcode? i really would rather not buy anything if its at all possible.

Xcode IS Applescript studio, essentially… and it’s available to anyone who owns a mac that can run it. Xcode allows you to build ASStudio projects, cocoa, carbon, whatever. When you create a new project, just select the type of applescript application you want to create and go from there. The learning curve it a bit steep at first, but there’s a lot of help here in the ASStudio forum and a good selection of mediocre sample projects in the ‘developer/examples’ directory.

Xcode comes with OSX. If you have a full OSX installation you may already have the installer on hard disk. Go to “/Applications/Installers/Developer Tools/Developer.mpkg” and install the tools. Otherwise, it’s on the the xcode/developer tools disk that came with your distribution of OSX. You can also join the Apple Developer Connection and download the disk image of xcode 1.5 for free.

Cheers,
j

as i said earlier, i have 10.2.8 (jaguar)

Hey Phreak! have you tried this snippet of code…

do shell script "any command" with administrator privileges

It brings up the System Admin password dialog window and errors if the incorrect password is entered.

Warning: if the correct password is entered, the sudoers file will allow root access for 5 minutes (default)

I’d love to be able to put a folder action on a folder to pasword protect it. Is there a way that applescript can do this? I have xcode, but i’d prefer not to go that far, although I will if need be. Some posts have come close, but not quite. I thought there was a script posted a while ago, but I haven’t had any luck.

hmm cool script but is there a way to get Applescript Studio On jaguar? i’ve searched apple but couldn’t find a jaguar version.

If you have (or get) an apple id, go to the developer connection and log in. Remember, membership is FREE & easy. Click on “Download Software” then click on “Developer Tools”… you can find a link to the only version of the development tools still available from apple for 10.2.x, entitled “December 2002 Mac OS X Developer Tools” (301.2mb).

j