BlueSense AppleScripts

How to disable Mac OS X session auto login in AppleScript

Disable the Mac OS X automatic login session and prompt for the password next time the computer will start.

script DisableAutomaticLogin
		set my_password to getPassword(KeychainPasswordName)
		set my_username to getUsername()
		do shell script ("/usr/bin/defaults delete /Library/Preferences/ autoLoginUser") user name my_username password my_password with administrator privileges
	on error errString number errorNumber
		log (errString)
	end try
end script