Validating Username/password on Mac?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
hwbehrens
Posts: 19
Joined: Fri Mar 19, 2010 9:10 pm

Validating Username/password on Mac?

Post by hwbehrens » Fri Jan 20, 2012 1:58 am

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.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Validating Username/password on Mac?

Post by Mark » Fri Jan 20, 2012 11:53 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

hwbehrens
Posts: 19
Joined: Fri Mar 19, 2010 9:10 pm

Re: Validating Username/password on Mac?

Post by hwbehrens » Fri Jan 20, 2012 5:05 pm

Mark,

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

Post Reply