Apple introduced a new "feature" with MacOSX Lion (10.7) which is called Captive Network Assistant. In my opinion its just a useless and annoying feature. It's aim is to help you login to networks which require authentication (see: Captive Portal), but the feature doesn't store cookies or saves passwords.
In my university we also use such a network which requires users to login. The login doesn't happen via browser but via VPN, which makes the Captive Network Assistant completely useless and annoying.
So im posting a Guide here on how to replace this "feature" with something actually useful and i didn't want it to get lost and be useful to other people
#1. create a bash script with name "Captive Network Assistant", paste the following code inside and replace your file with the same at /System/Library/CoreServices/Captive Network Assistant.app/Contents/MacOS/
#!/bin/bash
scriptlocation="/System/Library/CoreServices/Captive Network Assistant.app/Contents/MacOS/vpn.scpt"
osascript "$scriptlocation"
#2. create an applescript with name "vpn.scpt", place it under the path mentioned in the bash-script and place the following code inside:
set wlanssid to do shell script "networksetup -getairportnetwork en1 | cut -c 24-"
connectVPN(wlanssid)
on connectVPN(SSID)
tell application "System Events"
tell current location of network preferences
local VPNService
if (SSID = "XYZXYZ") then --WLANNAME
set VPNService to service "XYZXYZ-VPN" --VPNNAME
set isConnected to connected of current configuration of VPNService
if not isConnected then
connect VPNService
end if
end if
end tell
end tell
end connectVPN
This script will be executed everytime your computer connects to a "Captive Network" and if the SSID of the WLAN is called "XYZXYZ" it will start the VPN-Connection with name XYZXYZ-VPN
The script can be modified to support multiple captive networks.
Also its possible to add Growl-Notifications to the Script. My complete Script looks like this: http://pastebin.com/Rtp9EqQR