Script to set up System Level Authentication in 10.5

Since there’s no way to do it via Terminal in 10.5, I’ve got another script written to just add the network, but it creates a user level account, and I need it to be system level. I’m almost there, but keep running into 802.1X authentication errors when I try it, and I think the problem is that TTLS and PEAP are both checked. We authenticate via PEAP, so I’m trying to automate a way to uncheck TTLS in my script.

I’ve been using the click function to uncheck the box, and when I watch the script execute, the box unchecks for a split second, then checks again, the script finishes, and I’m riddled with authentication errors. Here’s the line I’m using to uncheck:

If it matters, I’m not actually running this as a saved Applescript, but rather, through the “osascript -e” function in Bash, since I’m deploying via ARD and have other steps that I need to run first as root user.

Any help would be greatly appreciated! Thank you in advance.

Noah

tell application "System Preferences"
activate
end tell
tell application "System Events"
tell application process "System Preferences"
delay 0.5
keystroke "Airport"
delay 2
keystroke return
delay 1
click button "Advanced."  of window "Network" 
delay 1
click radio button "802.1X"  of tab group 1 of sheet 1 of window "Network" 
delay 1
		click UI element 1 of group 1 of row 1 of outline 1 of scroll area 1 of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events"
		delay 0.5
		keystroke tab
delay 0.5
		keystroke tab
delay 0.5		
keystroke tab
delay 0.5		
keystroke tab
delay 0.5		
keystroke tab
		delay 0.5
		click button "Delete Profile" of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events"
delay 0.5
		click button "Delete Profile" of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events"
		delay 1
click menu button "Add Profile" of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events"
delay 0.5
click menu item "Add System Profile" of menu "Add Profile" of menu button "Add Profile" of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events"
keystroke tab
delay 0.5
keystroke tab
delay 0.5
keystroke "USERNAME"
		delay 0.5
		keystroke tab
		delay 0.5
		keystroke "PASSWORD"
delay 0.5
keystroke tab
delay 0.5
click button 1 of combo box 1 of group 1 of group 1 of tab group 1 of sheet 1 of window "Network"
delay 0.5
keystroke "NETWORKNAME"
delay 0.5
keystroke return
delay 1
keystroke tab
delay 0.5
click checkbox 1 of row 1 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events"
delay 1
click button "OK" of sheet 1 of window "Network"
delay 0.5
click button "Apply" of window "Network"
delay 1
do shell script "networksetup -setairportpower off"
delay 5
do shell script "networksetup -setairportpower on"
delay 3
	end tell
end tell

Hello.

I wonder if you have tried setting the value of the checkbox instead of clicking it, or tried to set that value first, or after?

set value of  checkbox 1 of row 1 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events" to 1

It is the only tricks I can think of, besides

set focused of  checkbox 1 of row 1 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1 of window "Network" of application process "System Preferences" of application "System Events" to true

I really can’t fathom why the preferences pane acts like that, because that technique usually works. Maybe it has something to do with the fact that is is about security? (That is a wild speculation.)

Edit

I think the set value may generate a run time error, so please just have a short delay, then a try block, try setting the value, and click on the item in the on error clause.

I hope you understand what I mean, it is late.

Another approach, would be to see if you can find that value in some property list file, change the value in the property list file, display the preferences pane, and close it, in order to activate the property.

Hello.

A much better way to throw an error, for the hope that the resistance breaks down, as the code in the try block is executed outside the normal realm is:

try
	set trap to undecl
on error
	-- perform click here
end try

I have the highest hope, for finding the value in a property list file, or in the defaults database, write the value in the respective place, then activate the preference pane, in order to force it to reread the property, and enable it, before just closing the preference pane again

Edit

I don’t think that executing the click in an error block will do much good after all. And if it doesn’t work to set the property, and activate it, as described above, then you need to grant yourself authorization first, since I think the lack of authorization to be the culprit.

I really appreciate all of your help on this, but none of the above suggestions in any combination seem to have made a difference. I’m running PlistBuddy commands to allow access for modification for all users. I’ve tried it under standard and administrative users, and the authorization doesn’t seem to be an issue in that respect:

As far as a .plist, I know that when setting authentication protocols for a user profile, it writes to com.apple.eap.profiles.plist, but for system level, it looks like it’s writing to /Library/Preferences/SystemConfiguration/preferences.plist. I’ll mess around with defaults write to see if I can modify just the accepted EAP types, but I don’t think it’ll work before I have a system configuration already in place. Arghhhhhhh 10.5 is a bad OS.

Best of Luck.

Just remember the trick of opening the anchor of the System Preferences for the network settings to activate them when you are done. (Learned by DJ Bazzie Wazzie.)