Page 1 of 1

Validating Username/password on Mac?

Posted: Fri Jan 20, 2012 1:58 am
by hwbehrens
I am looking for a way to validate a given username/password pair on Mac OS X. My first thought was to approach it using shell. I am currently using:

Code: Select all

echo <password> | sudo -S ls -a
and then checking to see if the result includes "..", but this is obviously not ideal. Even worse, it only allows me to validate the password against the current user, not any user.

Ideally, I would be able to use

Code: Select all

su <username>; echo <password>
or something like that, and then look for 'sorry', but the way the shell command works in Livecode doesn't seem to allow this. I've tried using 'expect' to approximate it, but so far no luck.

Has anyone had any luck checking the validity of system usernames/passwords on Mac? I am not married to the shell approach by any means.

Re: Validating Username/password on Mac?

Posted: Fri Jan 20, 2012 11:53 am
by Mark
Hi,

It is a good thing that you can't just do this, because it would be a big security hole.

If you want to show the password dialog in LiveCode, use AppleScript with admin privileges:

Code: Select all

do shell script "ls -a" with administrator privileges
Whenever you run into an issue that needs admin privileges, you are probably going to need the shell, which is made possible by AppleScript.

Kind regards,

Mark

Re: Validating Username/password on Mac?

Posted: Fri Jan 20, 2012 5:05 pm
by hwbehrens
Mark,

Thanks for the suggestion. I really just needed to execute a shell command with admin privileges, so your solution seems ideal.