Ignoring Failed Authentication

Hello,

I have a problem that I’m at my wits end at resolving. I would like to check to see if a user name and password is valid on a remote machine. The issue is, if the name and password is incorrect, OS X presents a failed authentication dialog.

One possibility that came to me is using SSH or rlogin to attempt to login in through the shell; however, I can’t find any commands that allow me to connect to a remote machine without forcing a separate password line.

Ideally, I would just like to have a “failed” result and provide the error handling myself. I’ve looked into trying SSH, rlogin, ignoring application responses, error handling…just about anything I can think of. Help!

Here is an example:

on VerifyAuthentication(wUserInfo)
	
	set sEPPCAddy to "eppc://" & admin_name of wUserInfo & ":" & admin_password of wUserInfo & "@" & ip_address of wUserInfo
	
	try
		with timeout of 3 seconds
			using terms from application "Finder"
				tell application "Finder" of machine sEPPCAddy
                                   --  do something mindless--just to see if we can log in
					do shell script "echo"
				end tell
			end using terms from
		end timeout
		
	on error
		
		return false
		
	end try
	
	return true
	
end VerifyAuthentication

Thanks!!!

To answer my own question, I think I have a solution: handing it off to a shell script with an expect call.

(Yeah, I suspect this should be moved/copied into the Terminal forum…)

Create a shell script like the following:

#!/usr/bin/expect

spawn ssh [lindex $argv 0]
set password [lindex $argv 1]
expect “password:”
send “$password\r”
expect eof

(saved, in the below example, as “your_shelL_script” in the bin folder)

Then, in your script, call:

set theResult to do shell script “/bin/your_shell_script @ ”

if the second to last line of theResult is “Welcome to Darwin!”, the password worked. If it’s anything else, it failed.

Whew. That’s a lot of work just to ignore a dialog…!! If anyone has a better way, I’m open to suggestions.

[cats]